diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-18 18:42:52 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-18 18:42:52 +0000 |
| commit | 81177c5dac1311377aadde80303faddc0c74f609 (patch) | |
| tree | 27a3bf5ad83ae9b2daeaba3ce68bcc0f1ead1717 /llvm | |
| parent | 3e1f15abc28c71ec6d28a37240299a51bae515d9 (diff) | |
| download | bcm5719-llvm-81177c5dac1311377aadde80303faddc0c74f609.tar.gz bcm5719-llvm-81177c5dac1311377aadde80303faddc0c74f609.zip | |
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.
llvm-svn: 186595
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Support/Windows/Path.inc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc index 5d951425384..dff89c74b16 100644 --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/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: |

