Ensure that functions like isDirectory don't fail if the file doesn't
exist but just return false instead.
llvm-svn: 22361
diff --git a/llvm/lib/System/Win32/Path.inc b/llvm/lib/System/Win32/Path.inc
index a049f16..2524310 100644
--- a/llvm/lib/System/Win32/Path.inc
+++ b/llvm/lib/System/Win32/Path.inc
@@ -213,6 +213,8 @@
bool
Path::isDirectory() const {
+ if (!exists())
+ return false;
WIN32_FILE_ATTRIBUTE_DATA fi;
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
ThrowError(std::string(path) + ": Can't get status: ");
@@ -221,6 +223,8 @@
bool
Path::isHidden() const {
+ if (!exists())
+ return false;
WIN32_FILE_ATTRIBUTE_DATA fi;
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
ThrowError(std::string(path) + ": Can't get status: ");
@@ -248,6 +252,8 @@
bool
Path::isBytecodeFile() const {
+ if (!isFile())
+ return false;
std::string actualMagic;
if (!getMagicNumber(actualMagic, 4))
return false;