From aceaa69427f09e4cf248789d43bb683a8409e1f5 Mon Sep 17 00:00:00 2001 From: Christopher Olofsson Date: Tue, 4 Feb 2020 20:41:44 +0100 Subject: [PATCH] Fix path normalizations with correct case for all directories. --- src/platform_win.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/platform_win.cc b/src/platform_win.cc index 2546fa00e..0cd00612c 100644 --- a/src/platform_win.cc +++ b/src/platform_win.cc @@ -93,7 +93,13 @@ optional NormalizePath(const std::string& path0, // and this function is called with `c:\fooBar` this will return `c:\FooBar`. // (drive casing is lowercase). if (ensure_exists) { - len = GetLongPathName(path.c_str(), buffer, MAX_PATH); + // Ensure 'GetLongPathName' actually transforms every path segment to the correct + // case by first making all directories in 8.3 format. + len = GetShortPathName(path.c_str(), buffer, MAX_PATH); + if (!len) + return nullopt; + std::string shortPath(buffer, len); + len = GetLongPathName(shortPath.c_str(), buffer, MAX_PATH); if (!len) return nullopt; path = std::string(buffer, len);