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

Function DoWriteStringToFile

src/leveldb/util/env.cc:34–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34static Status DoWriteStringToFile(Env* env, const Slice& data,
35 const std::string& fname, bool should_sync) {
36 WritableFile* file;
37 Status s = env->NewWritableFile(fname, &file);
38 if (!s.ok()) {
39 return s;
40 }
41 s = file->Append(data);
42 if (s.ok() && should_sync) {
43 s = file->Sync();
44 }
45 if (s.ok()) {
46 s = file->Close();
47 }
48 delete file; // Will auto-close if we did not close above
49 if (!s.ok()) {
50 env->DeleteFile(fname);
51 }
52 return s;
53}
54
55Status WriteStringToFile(Env* env, const Slice& data,
56 const std::string& fname) {

Callers 2

WriteStringToFileFunction · 0.85
WriteStringToFileSyncFunction · 0.85

Calls 5

NewWritableFileMethod · 0.45
AppendMethod · 0.45
SyncMethod · 0.45
CloseMethod · 0.45
DeleteFileMethod · 0.45

Tested by

no test coverage detected