MCPcopy Create free account
hub / github.com/apache/impala / DoWriteStringToFile

Function DoWriteStringToFile

be/src/kudu/util/env.cc:27–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27static Status DoWriteStringToFile(Env* env, const Slice& data,
28 const std::string& fname,
29 bool should_sync,
30 bool is_sensitive) {
31 unique_ptr<WritableFile> file;
32 WritableFileOptions opts;
33 opts.is_sensitive = is_sensitive;
34 Status s = env->NewWritableFile(opts, fname, &file);
35 if (!s.ok()) {
36 return s;
37 }
38 s = file->Append(data);
39 if (s.ok() && should_sync) {
40 s = file->Sync();
41 }
42 if (s.ok()) {
43 s = file->Close();
44 }
45 file.reset(); // Will auto-close if we did not close above
46 if (!s.ok()) {
47 WARN_NOT_OK(env->DeleteFile(fname),
48 "Failed to delete partially-written file " + fname);
49 }
50 return s;
51}
52
53// TODO: move these utils into env_util
54Status WriteStringToFile(Env* env, const Slice& data,

Callers 4

WriteStringToFileFunction · 0.85
WriteStringToFileSyncFunction · 0.85

Calls 7

NewWritableFileMethod · 0.80
resetMethod · 0.65
okMethod · 0.45
AppendMethod · 0.45
SyncMethod · 0.45
CloseMethod · 0.45
DeleteFileMethod · 0.45

Tested by

no test coverage detected