| 32 | } |
| 33 | |
| 34 | static 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 | |
| 55 | Status WriteStringToFile(Env* env, const Slice& data, |
| 56 | const std::string& fname) { |
no test coverage detected