diff options
Diffstat (limited to 'gn/src/gn/filesystem_utils.cc')
-rw-r--r-- | gn/src/gn/filesystem_utils.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gn/src/gn/filesystem_utils.cc b/gn/src/gn/filesystem_utils.cc index ae6d4d97ee9..3aec9ea4eb8 100644 --- a/gn/src/gn/filesystem_utils.cc +++ b/gn/src/gn/filesystem_utils.cc @@ -633,6 +633,11 @@ void NormalizePath(std::string* path, const std::string_view& source_root) { void ConvertPathToSystem(std::string* path) { #if defined(OS_WIN) + if (path->size() > 2) { + if (IsSlash((*path)[0]) && (*path)[2] == ':') { + *path = path->substr(1); + } + } for (size_t i = 0; i < path->size(); i++) { if ((*path)[i] == '/') (*path)[i] = '\\'; @@ -668,6 +673,13 @@ std::string MakeRelativePath(const std::string& input, corrected_input[letter_pos] = dest[letter_pos]; return MakeRelativePath(corrected_input, dest); } + // Give up if the drive paths are different so we don't end up + // returning a meaningless result. + if (input[letter_pos] != dest[letter_pos]) { + std::string ret = input; + ConvertPathToSystem(&ret); + return ret; + } } #endif |