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.cc b/src/main/cpp/blaze.cc
index 9591a3c..e70a0b4 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -1020,7 +1020,7 @@
     if (KillRunningServerIfAny()) {
       globals->restart_reason = NEW_VERSION;
     }
-    unlink(installation_path.c_str());
+    UnlinkPath(installation_path.c_str());
     if (!SymlinkDirectories(globals->options.install_base.c_str(),
                             installation_path.c_str())) {
       pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR,
@@ -1037,7 +1037,6 @@
   }
 }
 
-
 // A signal-safe version of fprintf(stderr, ...).
 //
 // WARNING: any output from the blaze client may be interleaved
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc
index f8d9c7a..f1126db 100644
--- a/src/main/cpp/blaze_util.cc
+++ b/src/main/cpp/blaze_util.cc
@@ -201,7 +201,7 @@
 // Writes 'content' into file 'filename', and makes it executable.
 // Returns false on failure, sets errno.
 bool WriteFile(const string &content, const string &filename) {
-  DeleteFile(filename);  // We don't care about the success of this.
+  UnlinkPath(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,10 +218,8 @@
   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;
+bool UnlinkPath(const string &file_path) {
+  return unlink(file_path.c_str()) == 0;
 }
 
 // Returns true iff both stdout and stderr are connected to a
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();