aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/cpp/blaze_util.cc')
-rw-r--r--src/main/cpp/blaze_util.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc
index cde7523ff5..f8d9c7a245 100644
--- a/src/main/cpp/blaze_util.cc
+++ b/src/main/cpp/blaze_util.cc
@@ -201,7 +201,7 @@ bool ReadFile(const string &filename, string *content) {
// Writes 'content' into file 'filename', and makes it executable.
// Returns false on failure, sets errno.
bool WriteFile(const string &content, const string &filename) {
- unlink(filename.c_str());
+ DeleteFile(filename); // We don't care about the success of this.
int fd = open(filename.c_str(), O_CREAT|O_WRONLY|O_TRUNC, 0755); // chmod +x
if (fd == -1) {
return false;
@@ -218,6 +218,12 @@ bool WriteFile(const string &content, const string &filename) {
return static_cast<uint>(r) == content.size();
}
+// Deletes the file 'filename'.
+// Returns false on failure, sets errno.
+bool DeleteFile(const string &filename) {
+ return unlink(filename.c_str()) == 0;
+}
+
// Returns true iff both stdout and stderr are connected to a
// terminal, and it can support color and cursor movement
// (this is computed heuristically based on the values of