MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / writeFile

Function writeFile

src/helper/common/io_posix.cpp:29–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29bool 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
45namespace {
46// Two overloads absorb the XSI-vs-GNU strerror_r() return-type split:

Callers 4

fullApplyMethod · 0.50
loadTableDefMethod · 0.50
loadAnchorMethod · 0.50
writeRulesFileMethod · 0.50

Calls 1

writeAllFunction · 0.85

Tested by

no test coverage detected