diff options
author | Nico Weber <thakis@chromium.org> | 2022-12-09 15:24:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-09 15:24:03 -0500 |
commit | c6e002d86d6657f18dd772c8138454291becf885 (patch) | |
tree | 7330ab36eb0904e0455b9fdcc3247ab2244b0e13 | |
parent | 53346f18fd4c90fa6f07a2b40e5c788ffe46e738 (diff) | |
parent | c47ff5aa33d0928f20d06986f8331e3bb5eba3bc (diff) | |
download | ninja-c6e002d86d6657f18dd772c8138454291becf885.tar.gz |
Merge pull request #2160 from zmodem/fix_FindFirstFileExA
Handle ERROR_DIRECTORY when calling FindFirstFileExA
-rw-r--r-- | src/disk_interface.cc | 3 | ||||
-rw-r--r-- | src/disk_interface_test.cc | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc index 7277c3e..1157463 100644 --- a/src/disk_interface.cc +++ b/src/disk_interface.cc @@ -110,7 +110,8 @@ bool StatAllFilesInDir(const string& dir, map<string, TimeStamp>* stamps, if (find_handle == INVALID_HANDLE_VALUE) { DWORD win_err = GetLastError(); - if (win_err == ERROR_FILE_NOT_FOUND || win_err == ERROR_PATH_NOT_FOUND) + if (win_err == ERROR_FILE_NOT_FOUND || win_err == ERROR_PATH_NOT_FOUND || + win_err == ERROR_DIRECTORY) return true; *err = "FindFirstFileExA(" + dir + "): " + GetLastErrorString(); return false; diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc index 7041d98..294df72 100644 --- a/src/disk_interface_test.cc +++ b/src/disk_interface_test.cc @@ -65,6 +65,17 @@ TEST_F(DiskInterfaceTest, StatMissingFile) { EXPECT_EQ("", err); } +TEST_F(DiskInterfaceTest, StatMissingFileWithCache) { + disk_.AllowStatCache(true); + string err; + + // On Windows, the errno for FindFirstFileExA, which is used when the stat + // cache is enabled, is different when the directory name is not a directory. + ASSERT_TRUE(Touch("notadir")); + EXPECT_EQ(0, disk_.Stat("notadir/nosuchfile", &err)); + EXPECT_EQ("", err); +} + TEST_F(DiskInterfaceTest, StatBadPath) { string err; #ifdef _WIN32 |