forked from OSchip/llvm-project
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
This commit is contained in:
parent
3e1f15abc2
commit
81177c5dac
|
@ -581,7 +581,14 @@ static error_code getStatus(HANDLE FileHandle, file_status &Result) {
|
||||||
|
|
||||||
switch (::GetFileType(FileHandle)) {
|
switch (::GetFileType(FileHandle)) {
|
||||||
default:
|
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:
|
case FILE_TYPE_DISK:
|
||||||
break;
|
break;
|
||||||
case FILE_TYPE_CHAR:
|
case FILE_TYPE_CHAR:
|
||||||
|
|
Loading…
Reference in New Issue