aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/util
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-01-10 16:41:23 +0000
committerGravatar Marcel Hlopko <hlopko@google.com>2017-01-10 19:42:18 +0000
commite1f8bbc1fe1d0a22736597dbd029155b01718b94 (patch)
tree3203fe21a2f164fd74914f3333b60e9c9ee5d8f6 /src/main/cpp/util
parent19948b036eb70dd768321082f31cd9f6563da522 (diff)
*** Reason for rollback *** Fixed the problem with the CL. *** Original change description *** Bazel client, Windows: implement UnlinkPath See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 144087552 MOS_MIGRATED_REVID=144087552
Diffstat (limited to 'src/main/cpp/util')
-rw-r--r--src/main/cpp/util/file_posix.cc8
-rw-r--r--src/main/cpp/util/file_windows.cc6
2 files changed, 10 insertions, 4 deletions
diff --git a/src/main/cpp/util/file_posix.cc b/src/main/cpp/util/file_posix.cc
index 466bae499d..9d7f772d2d 100644
--- a/src/main/cpp/util/file_posix.cc
+++ b/src/main/cpp/util/file_posix.cc
@@ -209,15 +209,15 @@ bool WriteFile(const void *data, size_t size, const string &filename) {
return result;
}
-bool UnlinkPath(const string &file_path) {
- return unlink(file_path.c_str()) == 0;
-}
-
// TODO(bazel-team): implement all functions in file_windows.cc, use them from
// MSYS, remove file_posix.cc from the `srcs` of
// //src/main/cpp/util:file when building for MSYS, and remove all
// #ifndef __CYGWIN__ directives.
#ifndef __CYGWIN__
+bool UnlinkPath(const string &file_path) {
+ return unlink(file_path.c_str()) == 0;
+}
+
bool PathExists(const string& path) {
return access(path.c_str(), F_OK) == 0;
}
diff --git a/src/main/cpp/util/file_windows.cc b/src/main/cpp/util/file_windows.cc
index 3a5b5ac8e4..ba3e777d2b 100644
--- a/src/main/cpp/util/file_windows.cc
+++ b/src/main/cpp/util/file_windows.cc
@@ -43,6 +43,12 @@ static unique_ptr<WCHAR[]> GetCwdW();
// necessary.
static bool IsDirectoryW(const wstring& path);
+// Returns true the file or junction at `path` is successfully deleted.
+// Returns false otherwise, or if `path` doesn't exist or is a directory.
+// `path` must be a normalized Windows path, with UNC prefix (and absolute) if
+// necessary.
+static bool UnlinkPathW(const wstring& path);
+
// Like `AsWindowsPath` but the result is absolute and has UNC prefix if needed.
static bool AsWindowsPathWithUncPrefix(const string& path, wstring* wpath);