| 27 | } |
| 28 | |
| 29 | bool writeFile(const std::string &path, const std::string &content, int mode) |
| 30 | { |
| 31 | unlink(path.c_str()); |
| 32 | int fd = open(path.c_str(), O_CREAT | O_WRONLY | O_TRUNC, mode); |
| 33 | if (fd < 0) { |
| 34 | return false; |
| 35 | } |
| 36 | if (!writeAll(fd, content)) { |
| 37 | close(fd); |
| 38 | unlink(path.c_str()); |
| 39 | return false; |
| 40 | } |
| 41 | close(fd); |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | namespace { |
| 46 | // Two overloads absorb the XSI-vs-GNU strerror_r() return-type split: |
no test coverage detected