diff options
author | 2017-01-10 15:51:06 +0000 | |
---|---|---|
committer | 2017-01-10 15:53:50 +0000 | |
commit | 284bbda34a3405779da67dc4fa15ef0fea76a88e (patch) | |
tree | dcd6d6fcb39827a53b98f7df4b437a1bd13b977f /src/main/cpp/util/file_windows.cc | |
parent | 62a6f695f95b8dde15fe9b287a290dc7ac06e173 (diff) |
Rollback of commit 9a13899b1492738f8d1a9118cebc9ef9d90c6b34.
*** Reason for rollback ***
Breaks windows:
bazel-out/local-fastbuild/bin/src/main/cpp/util/libfile.a(file_windows.o):file_windows.cc:(.text+0x11e2): multiple definition of `blaze_util::UnlinkPath(std::string const&)'
bazel-out/local-fastbuild/bin/src/main/cpp/util/libfile.a(file_posix.o):file_posix.cc:(.text+0x3ff): first defined here
*** Original change description ***
Bazel client, Windows: implement UnlinkPath
See https://github.com/bazelbuild/bazel/issues/2107
--
PiperOrigin-RevId: 144082937
MOS_MIGRATED_REVID=144082937
Diffstat (limited to 'src/main/cpp/util/file_windows.cc')
-rw-r--r-- | src/main/cpp/util/file_windows.cc | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/src/main/cpp/util/file_windows.cc b/src/main/cpp/util/file_windows.cc index 758bfb71dc..2b4a105f05 100644 --- a/src/main/cpp/util/file_windows.cc +++ b/src/main/cpp/util/file_windows.cc @@ -38,12 +38,6 @@ using std::wstring; // The result may have a UNC prefix. static unique_ptr<WCHAR[]> GetCwdW(); -// 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); @@ -390,32 +384,14 @@ bool WriteFile(const void* data, size_t size, const string& filename) { #else // not COMPILER_MSVC #endif // COMPILER_MSVC -static bool UnlinkPathW(const wstring& path) { - DWORD attrs = ::GetFileAttributesW(path.c_str()); - if (attrs == INVALID_FILE_ATTRIBUTES) { - // Path does not exist. - return false; - } - if (attrs & FILE_ATTRIBUTE_DIRECTORY) { - if (!(attrs & FILE_ATTRIBUTE_REPARSE_POINT)) { - // Path is a directory; unlink(2) also cannot remove directories. - return false; - } - // Otherwise it's a junction, remove using RemoveDirectoryW. - return ::RemoveDirectoryW(path.c_str()) == TRUE; - } else { - // Otherwise it's a file, remove using DeleteFileW. - return ::DeleteFileW(path.c_str()) == TRUE; - } -} - +#ifdef COMPILER_MSVC bool UnlinkPath(const string& file_path) { - wstring wpath; - if (!AsWindowsPathWithUncPrefix(file_path, &wpath)) { - return false; - } - return UnlinkPathW(wpath); + // TODO(bazel-team): implement this. + pdie(255, "blaze_util::UnlinkPath is not implemented on Windows"); + return false; } +#else // not COMPILER_MSVC +#endif // COMPILER_MSVC HANDLE OpenDirectory(const WCHAR* path, bool read_write) { return ::CreateFileW( |