mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 23:31:37 +00:00
Implement getUniqueID for directories on windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187441 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8838da6587
commit
f4ab63f3d8
@ -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) {
|
||||
|
@ -195,6 +195,19 @@ TEST_F(FileSystemTest, Unique) {
|
||||
ASSERT_EQ(D2, F1);
|
||||
|
||||
::close(FileDescriptor);
|
||||
|
||||
SmallString<128> Dir1;
|
||||
ASSERT_NO_ERROR(
|
||||
fs::createUniqueDirectory("dir1", Dir1));
|
||||
ASSERT_NO_ERROR(fs::getUniqueID(Dir1.c_str(), F1));
|
||||
ASSERT_NO_ERROR(fs::getUniqueID(Dir1.c_str(), F2));
|
||||
ASSERT_EQ(F1, F2);
|
||||
|
||||
SmallString<128> Dir2;
|
||||
ASSERT_NO_ERROR(
|
||||
fs::createUniqueDirectory("dir2", Dir2));
|
||||
ASSERT_NO_ERROR(fs::getUniqueID(Dir2.c_str(), F2));
|
||||
ASSERT_NE(F1, F2);
|
||||
}
|
||||
|
||||
TEST_F(FileSystemTest, TempFiles) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user