diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-30 20:25:53 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-30 20:25:53 +0000 |
commit | f4ab63f3d8efa70053786d8a0e57b3bf76ae4ee5 (patch) | |
tree | eded553504522fd281f273bf5f9b08aca87cbdec /lib/Support | |
parent | 8838da6587e60a248b07d4db0e874429ad4e9747 (diff) | |
download | external_llvm-f4ab63f3d8efa70053786d8a0e57b3bf76ae4ee5.zip external_llvm-f4ab63f3d8efa70053786d8a0e57b3bf76ae4ee5.tar.gz external_llvm-f4ab63f3d8efa70053786d8a0e57b3bf76ae4ee5.tar.bz2 |
Implement getUniqueID for directories on windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Windows/Path.inc | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index a0724e5..c1dac91 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -592,12 +592,17 @@ static error_code getStatus(HANDLE FileHandle, file_status &Result) { if (!::GetFileInformationByHandle(FileHandle, &Info)) goto handle_status_error; - Result = file_status( - file_type::regular_file, Info.ftLastWriteTime.dwHighDateTime, - Info.ftLastWriteTime.dwLowDateTime, Info.dwVolumeSerialNumber, - Info.nFileSizeHigh, Info.nFileSizeLow, Info.nFileIndexHigh, - Info.nFileIndexLow); - return error_code::success(); + { + file_type Type = (Info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + ? file_type::directory_file + : file_type::regular_file; + Result = + file_status(Type, Info.ftLastWriteTime.dwHighDateTime, + Info.ftLastWriteTime.dwLowDateTime, + Info.dwVolumeSerialNumber, Info.nFileSizeHigh, + Info.nFileSizeLow, Info.nFileIndexHigh, Info.nFileIndexLow); + return error_code::success(); + } handle_status_error: error_code EC = windows_error(::GetLastError()); @@ -644,23 +649,14 @@ error_code status(const Twine &path, file_status &result) { return getStatus(INVALID_HANDLE_VALUE, result); } - if (attr & FILE_ATTRIBUTE_DIRECTORY) - result = file_status(file_type::directory_file); - else { - ScopedFileHandle h( - ::CreateFileW(path_utf16.begin(), - 0, // Attributes only. + ScopedFileHandle h( + ::CreateFileW(path_utf16.begin(), 0, // Attributes only. FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - 0)); + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0)); if (!h) return getStatus(INVALID_HANDLE_VALUE, result); return getStatus(h, result); - } - return error_code::success(); } error_code status(int FD, file_status &Result) { |