MCPcopy Create free account
hub / github.com/ElementsProject/elements / SetCurrentFile

Function SetCurrentFile

src/leveldb/db/filename.cc:123–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123Status SetCurrentFile(Env* env, const std::string& dbname,
124 uint64_t descriptor_number) {
125 // Remove leading "dbname/" and add newline to manifest file name
126 std::string manifest = DescriptorFileName(dbname, descriptor_number);
127 Slice contents = manifest;
128 assert(contents.starts_with(dbname + "/"));
129 contents.remove_prefix(dbname.size() + 1);
130 std::string tmp = TempFileName(dbname, descriptor_number);
131 Status s = WriteStringToFileSync(env, contents.ToString() + "\n", tmp);
132 if (s.ok()) {
133 s = env->RenameFile(tmp, CurrentFileName(dbname));
134 }
135 if (!s.ok()) {
136 env->DeleteFile(tmp);
137 }
138 return s;
139}
140
141} // namespace leveldb

Callers 3

NewDBMethod · 0.85
WriteDescriptorMethod · 0.85
LogAndApplyMethod · 0.85

Calls 8

DescriptorFileNameFunction · 0.85
TempFileNameFunction · 0.85
WriteStringToFileSyncFunction · 0.85
CurrentFileNameFunction · 0.85
sizeMethod · 0.45
ToStringMethod · 0.45
RenameFileMethod · 0.45
DeleteFileMethod · 0.45

Tested by

no test coverage detected