MCPcopy Create free account
hub / github.com/baidu/tera / DoWriteStringToFile

Function DoWriteStringToFile

src/leveldb/util/env.cc:56–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56static Status DoWriteStringToFile(Env* env, const Slice& data, const std::string& fname,
57 bool should_sync) {
58 WritableFile* file;
59 Status s = env->NewWritableFile(fname, &file, EnvOptions());
60 if (!s.ok()) {
61 return s;
62 }
63 s = file->Append(data);
64 if (s.ok() && should_sync) {
65 s = file->Sync();
66 }
67 if (s.ok()) {
68 s = file->Close();
69 }
70 delete file; // Will auto-close if we did not close above
71 if (!s.ok()) {
72 env->DeleteFile(fname);
73 }
74 return s;
75}
76
77Status WriteStringToFile(Env* env, const Slice& data, const std::string& fname) {
78 return DoWriteStringToFile(env, data, fname, false);

Callers 2

WriteStringToFileFunction · 0.85
WriteStringToFileSyncFunction · 0.85

Calls 7

EnvOptionsClass · 0.85
NewWritableFileMethod · 0.45
okMethod · 0.45
AppendMethod · 0.45
SyncMethod · 0.45
CloseMethod · 0.45
DeleteFileMethod · 0.45

Tested by

no test coverage detected