summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-12-23 18:56:04 (GMT)
committerEvan Martin <martine@danga.com>2011-12-23 18:56:04 (GMT)
commite9ffd8dfbadcf9eb0963e30be3f989b7ef70d01d (patch)
tree66d96bd0906c4a6efa9e58e9e7682598d4dc96ae /src
parent63fff5fd371f590780f010582ae3aea52efde7c8 (diff)
downloadNinja-e9ffd8dfbadcf9eb0963e30be3f989b7ef70d01d.zip
Ninja-e9ffd8dfbadcf9eb0963e30be3f989b7ef70d01d.tar.gz
Ninja-e9ffd8dfbadcf9eb0963e30be3f989b7ef70d01d.tar.bz2
windows: handle ERROR_PATH_NOT_FOUND
From Frances <frances.buontempo@gmail.com>.
Diffstat (limited to 'src')
-rw-r--r--src/disk_interface.cc3
-rw-r--r--src/disk_interface_test.cc11
2 files changed, 8 insertions, 6 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc
index b60cd6f..4227f8f 100644
--- a/src/disk_interface.cc
+++ b/src/disk_interface.cc
@@ -69,7 +69,8 @@ int RealDiskInterface::Stat(const std::string& path) {
#ifdef WIN32
WIN32_FILE_ATTRIBUTE_DATA attrs;
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &attrs)) {
- if (GetLastError() == ERROR_FILE_NOT_FOUND)
+ DWORD err = GetLastError();
+ if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
return 0;
Error("GetFileAttributesEx(%s): %s", path.c_str(),
GetLastErrorString().c_str());
diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc
index d0794fd..3bb8067 100644
--- a/src/disk_interface_test.cc
+++ b/src/disk_interface_test.cc
@@ -109,16 +109,17 @@ class DiskInterfaceTest : public testing::Test {
TEST_F(DiskInterfaceTest, StatMissingFile) {
EXPECT_EQ(0, disk_.Stat("nosuchfile"));
+
+ // On Windows, the errno for a file in a nonexistent directory
+ // is different.
+ EXPECT_EQ(0, disk_.Stat("nosuchdir/nosuchfile"));
}
TEST_F(DiskInterfaceTest, StatBadPath) {
-#ifdef _WIN32
- string bad_path = "cc:\\foo";
- EXPECT_EQ(-1, disk_.Stat(bad_path));
-#else
+ // To test the error code path, use an overlong file name.
+ // Both Windows and Linux appear to object to this.
string too_long_name(512, 'x');
EXPECT_EQ(-1, disk_.Stat(too_long_name));
-#endif
}
TEST_F(DiskInterfaceTest, StatExistingFile) {