diff options
| author | tedin7 <tommasoderosa94@gmail.com> | 2026-11-23 22:25:45 +0100 |
|---|---|---|
| committer | tedin7 <tommasoderosa94@gmail.com> | 2026-11-23 22:25:45 +0100 |
| commit | 28716daea5876004467c1c5612d984b61b663dbc (patch) | |
| tree | ab5921fd5d5ea200f74827450ef818f193ef7ff0 /runtime/shims/file_system.cpp | |
| parent | 5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (diff) | |
file_system: check CopyFile2 cancellation before preparing destination
Diffstat (limited to 'runtime/shims/file_system.cpp')
| -rw-r--r-- | runtime/shims/file_system.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/shims/file_system.cpp b/runtime/shims/file_system.cpp index a7b64d75c..8efe705cb 100644 --- a/runtime/shims/file_system.cpp +++ b/runtime/shims/file_system.cpp | |||
| @@ -1289,14 +1289,14 @@ HRESULT WINAPI copy_file2(PCWSTR from, PCWSTR to, COPYFILE2_EXTENDED_PARAMETERS* | |||
| 1289 | if (parameters && parameters->dwSize < sizeof(COPYFILE2_EXTENDED_PARAMETERS)) return E_INVALIDARG; | 1289 | if (parameters && parameters->dwSize < sizeof(COPYFILE2_EXTENDED_PARAMETERS)) return E_INVALIDARG; |
| 1290 | const CopyFile2Fn host = host_copy_file2(); | 1290 | const CopyFile2Fn host = host_copy_file2(); |
| 1291 | if (!host && !fallback_supports(parameters)) return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); | 1291 | if (!host && !fallback_supports(parameters)) return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); |
| 1292 | const bool fail_if_exists = parameters && (parameters->dwCopyFlags & COPY_FILE_FAIL_IF_EXISTS) != 0; | ||
| 1293 | std::filesystem::path source, destination; | ||
| 1294 | DWORD error = 0; | ||
| 1295 | if (!copy_paths(from, to, fail_if_exists, source, destination, error)) return HRESULT_FROM_WIN32(error); | ||
| 1296 | // A cancel flag already set is answered here, for the host's CopyFile2 as well as the fallback: Windows returns | 1292 | // A cancel flag already set is answered here, for the host's CopyFile2 as well as the fallback: Windows returns |
| 1297 | // ERROR_REQUEST_ABORTED and writes nothing, while Wine reads the flag in neither call (Wine 11.20's CopyFile2 logs | 1293 | // ERROR_REQUEST_ABORTED and writes nothing, while Wine reads the flag in neither call (Wine 11.20's CopyFile2 logs |
| 1298 | // "pfCancel is not supported" and copies, dlls/kernelbase/file.c copy_file; Wine 9 has only CopyFileExW). | 1294 | // "pfCancel is not supported" and copies, dlls/kernelbase/file.c copy_file; Wine 9 has only CopyFileExW). |
| 1299 | if (parameters && parameters->pfCancel && *parameters->pfCancel) return HRESULT_FROM_WIN32(ERROR_REQUEST_ABORTED); | 1295 | if (parameters && parameters->pfCancel && *parameters->pfCancel) return HRESULT_FROM_WIN32(ERROR_REQUEST_ABORTED); |
| 1296 | const bool fail_if_exists = parameters && (parameters->dwCopyFlags & COPY_FILE_FAIL_IF_EXISTS) != 0; | ||
| 1297 | std::filesystem::path source, destination; | ||
| 1298 | DWORD error = 0; | ||
| 1299 | if (!copy_paths(from, to, fail_if_exists, source, destination, error)) return HRESULT_FROM_WIN32(error); | ||
| 1300 | if (host) return host(source.c_str(), destination.c_str(), parameters); | 1300 | if (host) return host(source.c_str(), destination.c_str(), parameters); |
| 1301 | return copy_file2_fallback(source.c_str(), destination.c_str(), parameters); | 1301 | return copy_file2_fallback(source.c_str(), destination.c_str(), parameters); |
| 1302 | } | 1302 | } |