diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 18:48:08 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 18:48:08 -0500 |
| commit | 864337351bc11a250db77c2fcdd3ba6f1d0f455f (patch) | |
| tree | 1b9fb69662877977ec6b5da697206fd1bdcf929f /runtime/shims/file_system.cpp | |
| parent | 54ed404defd035465ece0f2beeb792cf51179691 (diff) | |
| parent | b06d096ad0943d5eda9bf1b17b3c3346688fc1f6 (diff) | |
Merge main into RT-LIST139 (#396)
Merged on top of the merge made for #395 (main 507029d1e plus RT-QUEUE35
and RT-ALLOC9). No conflicts.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/file_system.cpp')
| -rw-r--r-- | runtime/shims/file_system.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/runtime/shims/file_system.cpp b/runtime/shims/file_system.cpp index 75f5e9810..f6934c5ed 100644 --- a/runtime/shims/file_system.cpp +++ b/runtime/shims/file_system.cpp | |||
| @@ -355,6 +355,10 @@ std::vector<std::wstring> parent_of(const std::vector<std::wstring>& parts) { | |||
| 355 | return parts.empty() ? parts : std::vector<std::wstring>(parts.begin(), parts.end() - 1); | 355 | return parts.empty() ? parts : std::vector<std::wstring>(parts.begin(), parts.end() - 1); |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | DWORD missing_error(const Roots& r, const std::vector<std::wstring>& parts) { | ||
| 359 | return is_folder(r, parent_of(parts)) ? ERROR_FILE_NOT_FOUND : ERROR_PATH_NOT_FOUND; | ||
| 360 | } | ||
| 361 | |||
| 358 | // Whether a folder has nothing in the title's view: no overlay entry and no package entry that is not deleted. | 362 | // Whether a folder has nothing in the title's view: no overlay entry and no package entry that is not deleted. |
| 359 | bool empty_in_view(const Roots& r, const std::vector<std::wstring>& parts) { | 363 | bool empty_in_view(const Roots& r, const std::vector<std::wstring>& parts) { |
| 360 | std::error_code ec; | 364 | std::error_code ec; |
| @@ -1024,10 +1028,7 @@ BOOL WINAPI delete_file_w(LPCWSTR name) { | |||
| 1024 | removed = true; | 1028 | removed = true; |
| 1025 | } | 1029 | } |
| 1026 | } | 1030 | } |
| 1027 | if (!removed) { | 1031 | if (!removed) return fail_bool(missing_error(r, parts)); |
| 1028 | SetLastError(ERROR_FILE_NOT_FOUND); | ||
| 1029 | return FALSE; | ||
| 1030 | } | ||
| 1031 | return TRUE; | 1032 | return TRUE; |
| 1032 | } | 1033 | } |
| 1033 | 1034 | ||
| @@ -1116,7 +1117,7 @@ BOOL WINAPI remove_directory_w(LPCWSTR name) { | |||
| 1116 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); | 1117 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); |
| 1117 | if (drive_root(name, parts)) return fail_bool(ERROR_ACCESS_DENIED); // "GAME:" and "T:" themselves stay | 1118 | if (drive_root(name, parts)) return fail_bool(ERROR_ACCESS_DENIED); // "GAME:" and "T:" themselves stay |
| 1118 | const View v = view(r, parts); | 1119 | const View v = view(r, parts); |
| 1119 | if (v.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND); | 1120 | if (v.kind == Kind::None) return fail_bool(missing_error(r, parts)); |
| 1120 | if (v.kind == Kind::File) return fail_bool(ERROR_DIRECTORY); | 1121 | if (v.kind == Kind::File) return fail_bool(ERROR_DIRECTORY); |
| 1121 | if (!empty_in_view(r, parts)) return fail_bool(ERROR_DIR_NOT_EMPTY); | 1122 | if (!empty_in_view(r, parts)) return fail_bool(ERROR_DIR_NOT_EMPTY); |
| 1122 | 1123 | ||
| @@ -1153,7 +1154,7 @@ BOOL WINAPI move_file_ex_w(LPCWSTR from, LPCWSTR to, DWORD flags) { | |||
| 1153 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); | 1154 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); |
| 1154 | if (drive_root(from, src) || drive_root(to, dst)) return fail_bool(ERROR_ACCESS_DENIED); | 1155 | if (drive_root(from, src) || drive_root(to, dst)) return fail_bool(ERROR_ACCESS_DENIED); |
| 1155 | const View from_view = view(r, src); | 1156 | const View from_view = view(r, src); |
| 1156 | if (from_view.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND); | 1157 | if (from_view.kind == Kind::None) return fail_bool(missing_error(r, src)); |
| 1157 | const std::filesystem::path overlay_from = disk_path(r.overlay, src), overlay_to = disk_path(r.overlay, dst); | 1158 | const std::filesystem::path overlay_from = disk_path(r.overlay, src), overlay_to = disk_path(r.overlay, dst); |
| 1158 | if (same_entry(src, dst)) { | 1159 | if (same_entry(src, dst)) { |
| 1159 | // The destination is the source, so it is not "already there". The host succeeds at a move onto the same | 1160 | // The destination is the source, so it is not "already there". The host succeeds at a move onto the same |
| @@ -1404,7 +1405,7 @@ BOOL WINAPI set_file_attributes_w(LPCWSTR name, DWORD attributes) { | |||
| 1404 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); | 1405 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); |
| 1405 | if (parts.empty()) return fail_bool(ERROR_ACCESS_DENIED); | 1406 | if (parts.empty()) return fail_bool(ERROR_ACCESS_DENIED); |
| 1406 | const View v = view(r, parts); | 1407 | const View v = view(r, parts); |
| 1407 | if (v.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND); | 1408 | if (v.kind == Kind::None) return fail_bool(missing_error(r, parts)); |
| 1408 | 1409 | ||
| 1409 | // The attributes belong to the overlay copy: a package file is copied up and a package folder mirrored first, | 1410 | // The attributes belong to the overlay copy: a package file is copied up and a package folder mirrored first, |
| 1410 | // so the package keeps its own attributes and reads, which prefer the overlay, see the new ones. | 1411 | // so the package keeps its own attributes and reads, which prefer the overlay, see the new ones. |