cpp: some minor changes to the usage of DeleteFile() function
This functions was introduced by commit bf98f39d5d69: "Add the ability
to customize the bazel client's...", but at that time it didn't update
EnsureCorrectRunningVersion() function, that uses unlink() function, to
use DeleteFile() as well.
So this patch updates EnsureCorrectRunningVersion() to make use of it
now.
While there is nothing wrong with the current name, it is not very much
correct from the documentation point. If the path is a symlink, unlink()
will just the symbolic link and the file won't be removed (affected at all).
Otherwise, if it is just a normal file, it will just decrement the link
count of the file and when that count reaches zero (0) then the file
will longer be accessible.
So while at it we renamed the function to UnlinkPath(), but could just
stay as DeleteFile() if we wanted.
In this process we also improved the documentation for this function to
be a little more clear and removed moved it from the source file, since
the header file already has it.
For further reference, adhere to the documentation in
http://pubs.opengroup.org/onlinepubs/009695399/functions/unlink.html.
--
Change-Id: I0fc569f3324322cbc67a8fb540836c127f5c3399
Reviewed-on: https://bazel-review.googlesource.com/#/c/3061/
MOS_MIGRATED_REVID=116769254
diff --git a/src/main/cpp/blaze_util.h b/src/main/cpp/blaze_util.h
index 5cf8182..4a5a3ce 100644
--- a/src/main/cpp/blaze_util.h
+++ b/src/main/cpp/blaze_util.h
@@ -55,9 +55,9 @@
// Returns false on failure, sets errno.
bool WriteFile(const string &content, const string &filename);
-// Deletes the file 'filename'.
-// Returns false on failure, sets errno.
-bool DeleteFile(const string &filename);
+// Unlinks the file given by 'file_path'.
+// Returns true on success. In case of failure sets errno.
+bool UnlinkPath(const string &file_path);
// Returns true iff the current terminal can support color and cursor movement.
bool IsStandardTerminal();