mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-04 17:47:58 +00:00
Support/Windows/PathV2: Fix remove to handle both files and directories.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122882 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5bcdc7f7c4
commit
abce07328c
@ -268,17 +268,31 @@ error_code remove(const Twine &path, bool &existed) {
|
|||||||
SmallString<128> path_storage;
|
SmallString<128> path_storage;
|
||||||
SmallVector<wchar_t, 128> path_utf16;
|
SmallVector<wchar_t, 128> path_utf16;
|
||||||
|
|
||||||
|
file_status st;
|
||||||
|
if (error_code ec = status(path, st))
|
||||||
|
return ec;
|
||||||
|
|
||||||
if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
|
if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
|
||||||
path_utf16))
|
path_utf16))
|
||||||
return ec;
|
return ec;
|
||||||
|
|
||||||
if (!::DeleteFileW(path_utf16.begin())) {
|
if (st.type() == file_type::directory_file) {
|
||||||
error_code ec = windows_error(::GetLastError());
|
if (!::RemoveDirectoryW(c_str(path_utf16))) {
|
||||||
if (ec != windows_error::file_not_found)
|
error_code ec = windows_error(::GetLastError());
|
||||||
return ec;
|
if (ec != windows_error::file_not_found)
|
||||||
existed = false;
|
return ec;
|
||||||
} else
|
existed = false;
|
||||||
existed = true;
|
} else
|
||||||
|
existed = true;
|
||||||
|
} else {
|
||||||
|
if (!::DeleteFileW(c_str(path_utf16))) {
|
||||||
|
error_code ec = windows_error(::GetLastError());
|
||||||
|
if (ec != windows_error::file_not_found)
|
||||||
|
return ec;
|
||||||
|
existed = false;
|
||||||
|
} else
|
||||||
|
existed = true;
|
||||||
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user