[llvm] r186595 - Small improvement to the use of GetFileType:
Rafael Espindola
rafael.espindola at gmail.com
Thu Jul 18 11:42:52 PDT 2013
Author: rafael
Date: Thu Jul 18 13:42:52 2013
New Revision: 186595
URL: http://llvm.org/viewvc/llvm-project?rev=186595&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Support/Windows/Path.inc
Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=186595&r1=186594&r2=186595&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Thu Jul 18 13:42:52 2013
@@ -581,7 +581,14 @@ static error_code getStatus(HANDLE FileH
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:
More information about the llvm-commits
mailing list