summaryrefslogtreecommitdiff
path: root/lib/Support/Windows
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-18 18:42:52 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-18 18:42:52 +0000
commitef69f54fec8ba71b6624226e5e7bf7675b013bac (patch)
tree188f84d059a02f965f0cbeb4f0ee69826478ee05 /lib/Support/Windows
parentbe9dd85f44f2228a122b3102252c4334dab2ff0f (diff)
downloadllvm-ef69f54fec8ba71b6624226e5e7bf7675b013bac.tar.gz
llvm-ef69f54fec8ba71b6624226e5e7bf7675b013bac.tar.bz2
llvm-ef69f54fec8ba71b6624226e5e7bf7675b013bac.tar.xz
Small improvement to the use of GetFileType:
* assert that the return value is one of the documented values on msdn. * on FILE_TYPE_UNKNOWN, check GetLastError. Unfortunately I can't think of a way to get a FILE_TYPE_UNKNOWN on a test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186595 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Windows')
-rw-r--r--lib/Support/Windows/Path.inc9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index 5d95142538..dff89c74b1 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -581,7 +581,14 @@ static error_code getStatus(HANDLE FileHandle, file_status &Result) {
switch (::GetFileType(FileHandle)) {
default:
- case FILE_TYPE_UNKNOWN:
+ llvm_unreachable("Don't know anything about this file type");
+ case FILE_TYPE_UNKNOWN: {
+ DWORD Err = ::GetLastError();
+ if (Err != NO_ERROR)
+ return windows_error(Err);
+ Result = file_status(file_type::type_unknown);
+ return error_code::success();
+ }
case FILE_TYPE_DISK:
break;
case FILE_TYPE_CHAR: