mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
Fix windows' implementation of status when a file doesn't exist.
The unix one was returning no_such_file_or_directory, but the windows one was return success. Update the one one caller that was depending on the old behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187463 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -399,8 +399,15 @@ error_code remove(const Twine &path, bool &existed) {
|
|||||||
SmallVector<wchar_t, 128> path_utf16;
|
SmallVector<wchar_t, 128> path_utf16;
|
||||||
|
|
||||||
file_status st;
|
file_status st;
|
||||||
if (error_code ec = status(path, st))
|
error_code EC = status(path, st);
|
||||||
return ec;
|
if (EC) {
|
||||||
|
if (EC == windows_error::file_not_found ||
|
||||||
|
EC == windows_error::path_not_found) {
|
||||||
|
existed = false;
|
||||||
|
return error_code::success();
|
||||||
|
}
|
||||||
|
return EC;
|
||||||
|
}
|
||||||
|
|
||||||
if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
|
if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
|
||||||
path_utf16))
|
path_utf16))
|
||||||
@ -611,11 +618,9 @@ handle_status_error:
|
|||||||
Result = file_status(file_type::file_not_found);
|
Result = file_status(file_type::file_not_found);
|
||||||
else if (EC == windows_error::sharing_violation)
|
else if (EC == windows_error::sharing_violation)
|
||||||
Result = file_status(file_type::type_unknown);
|
Result = file_status(file_type::type_unknown);
|
||||||
else {
|
else
|
||||||
Result = file_status(file_type::status_error);
|
Result = file_status(file_type::status_error);
|
||||||
return EC;
|
return EC;
|
||||||
}
|
|
||||||
return error_code::success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code status(const Twine &path, file_status &result) {
|
error_code status(const Twine &path, file_status &result) {
|
||||||
|
@ -240,6 +240,10 @@ TEST_F(FileSystemTest, TempFiles) {
|
|||||||
ASSERT_NO_ERROR(fs::remove(Twine(TempPath2), TempFileExists));
|
ASSERT_NO_ERROR(fs::remove(Twine(TempPath2), TempFileExists));
|
||||||
EXPECT_TRUE(TempFileExists);
|
EXPECT_TRUE(TempFileExists);
|
||||||
|
|
||||||
|
error_code EC = fs::status(TempPath2.c_str(), B);
|
||||||
|
EXPECT_EQ(EC, errc::no_such_file_or_directory);
|
||||||
|
EXPECT_EQ(B.type(), fs::file_type::file_not_found);
|
||||||
|
|
||||||
// Make sure Temp2 doesn't exist.
|
// Make sure Temp2 doesn't exist.
|
||||||
ASSERT_NO_ERROR(fs::exists(Twine(TempPath2), TempFileExists));
|
ASSERT_NO_ERROR(fs::exists(Twine(TempPath2), TempFileExists));
|
||||||
EXPECT_FALSE(TempFileExists);
|
EXPECT_FALSE(TempFileExists);
|
||||||
|
Reference in New Issue
Block a user