summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Boye Petersen <martinboyepetersen@hotmail.com>2021-01-02 20:20:00 (GMT)
committerMartin Boye Petersen <martinboyepetersen@hotmail.com>2021-01-02 20:20:00 (GMT)
commit97b4008aa788116683bb752d7c79b44128c2c485 (patch)
treeb279ae0ab6461610a4540427fa61e9df49cf1735
parentfb824d27b39e10acb97f9b105df2d9485a4677e9 (diff)
downloadNinja-97b4008aa788116683bb752d7c79b44128c2c485.zip
Ninja-97b4008aa788116683bb752d7c79b44128c2c485.tar.gz
Ninja-97b4008aa788116683bb752d7c79b44128c2c485.tar.bz2
disk_interface: Improve the stat cache handling for case sensitive folders on Windows
The path used as argument to FindFirstFileExA is no longer being converted to lowercase. By not converting the path to lower case, case sensitive folders will now be handled correctly. Case insensitive folders still works as expected because casing doesn't matter on those. All entries in the stat cache remains lowercase to avoid potential cache misses.
-rw-r--r--src/disk_interface.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc
index 49af001..001b5b2 100644
--- a/src/disk_interface.cc
+++ b/src/disk_interface.cc
@@ -180,12 +180,13 @@ TimeStamp RealDiskInterface::Stat(const string& path, string* err) const {
dir = path;
}
- transform(dir.begin(), dir.end(), dir.begin(), ::tolower);
+ string dir_lowercase = dir;
+ transform(dir.begin(), dir.end(), dir_lowercase.begin(), ::tolower);
transform(base.begin(), base.end(), base.begin(), ::tolower);
- Cache::iterator ci = cache_.find(dir);
+ Cache::iterator ci = cache_.find(dir_lowercase);
if (ci == cache_.end()) {
- ci = cache_.insert(make_pair(dir, DirCache())).first;
+ ci = cache_.insert(make_pair(dir_lowercase, DirCache())).first;
if (!StatAllFilesInDir(dir.empty() ? "." : dir, &ci->second, err)) {
cache_.erase(ci);
return -1;