MCPcopy Create free account
hub / github.com/baidu/bfs / FindFile

Method FindFile

src/chunkserver/file_cache.cc:39–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39common::Cache::Handle* FileCache::FindFile(const std::string& file_path) {
40 common::Slice key(file_path);
41 common::Cache::Handle* handle = cache_->Lookup(key);
42 if (handle == NULL) {
43 int fd = open(file_path.c_str(), O_RDONLY);
44 if (fd < 0) {
45 LOG(WARNING, "File not found: %s", file_path.c_str());
46 return NULL;
47 }
48 FileEntity* file = new FileEntity;
49 file->fd = fd;
50 file->file_name = file_path;
51 handle = cache_->Insert(key, file, 1, &DeleteEntry);
52 }
53 return handle;
54}
55
56int64_t FileCache::ReadFile(const std::string& file_path, char* buf,
57 int64_t len, int64_t offset) {

Callers

nothing calls this directly

Calls 1

InsertMethod · 0.80

Tested by

no test coverage detected