Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Fix path normalizations with correct case for all directories. #886

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/platform_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ optional<AbsolutePath> 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);
Expand Down