diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-07-26 17:00:20 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-07-27 08:48:43 +0200 |
commit | 52b489c56dd379b2afd96ed4069bd37eaa1f66b4 (patch) | |
tree | a76a0b08226784fc5218d90e0319aa97a24327fa /src/main/cpp/util | |
parent | 12783c3e1f91211afb5208d613d753d45b2dca56 (diff) |
Windows: fix MakeDirectories regression
MakeDirectories can again create top-level
directories.
Fixes https://github.com/bazelbuild/bazel/issues/3454
Change-Id: I087d2a78bac5d2b4e8aa46ea7d1f9e7538781362
PiperOrigin-RevId: 163207073
Diffstat (limited to 'src/main/cpp/util')
-rw-r--r-- | src/main/cpp/util/file_windows.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main/cpp/util/file_windows.cc b/src/main/cpp/util/file_windows.cc index 8637cc1281..8cf3baa619 100644 --- a/src/main/cpp/util/file_windows.cc +++ b/src/main/cpp/util/file_windows.cc @@ -1159,14 +1159,13 @@ static bool MakeDirectoriesW(const wstring& path) { if (IsRootDirectoryW(path) || IsDirectoryW(path)) { return true; } - int last_separator = path.rfind(L"\\"); - if (last_separator < 0) { - // Since `path` is not a root directory, there must be at least one + wstring parent = SplitPathW(path).first; + if (parent.empty()) { + // Since `path` is not a root directory, there should have been at least one // directory above it. pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, "MakeDirectoriesW(%S), could not find dirname", path.c_str()); } - wstring parent = path.substr(0, last_separator); return MakeDirectoriesW(parent) && ::CreateDirectoryW(path.c_str(), NULL) == TRUE; } |