diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 18:33:53 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 18:33:53 -0500 |
| commit | 5866d6974e86fc2d39e6ce0691af63b354f6c8b9 (patch) | |
| tree | ec44bee22e9d3f9582444e6fda7d52aff05de388 /runtime/shims/file_system.cpp | |
| parent | 1d37e033eb7094f922492de777ee8f1d5cc63b23 (diff) | |
| parent | 3a0af1f1503307570d998cfe609a70a16c5bbad2 (diff) | |
Merge main into OLD-8161, T: overlay folder per process (#684)
Conflict in docs/boot.md, the --overlay switch: main now says the overlay defaults to
<game-dir>\overlay and the package is never written; this branch adds the per-process T: folder
inside the overlay. Kept main's sentence and appended the T: text after it.
Co-Authored-By: Claude Opus 5.5 <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 3e4cd97be..dd7fd77c9 100644 --- a/runtime/shims/file_system.cpp +++ b/runtime/shims/file_system.cpp | |||
| @@ -420,6 +420,10 @@ std::vector<std::wstring> parent_of(const std::vector<std::wstring>& parts) { | |||
| 420 | return parts.empty() ? parts : std::vector<std::wstring>(parts.begin(), parts.end() - 1); | 420 | return parts.empty() ? parts : std::vector<std::wstring>(parts.begin(), parts.end() - 1); |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | DWORD missing_error(const Roots& r, const std::vector<std::wstring>& parts) { | ||
| 424 | return is_folder(r, parent_of(parts)) ? ERROR_FILE_NOT_FOUND : ERROR_PATH_NOT_FOUND; | ||
| 425 | } | ||
| 426 | |||
| 423 | // Whether a folder has nothing in the title's view: no overlay entry and no package entry that is not deleted. | 427 | // Whether a folder has nothing in the title's view: no overlay entry and no package entry that is not deleted. |
| 424 | bool empty_in_view(const Roots& r, const std::vector<std::wstring>& parts) { | 428 | bool empty_in_view(const Roots& r, const std::vector<std::wstring>& parts) { |
| 425 | std::error_code ec; | 429 | std::error_code ec; |
| @@ -1117,10 +1121,7 @@ BOOL WINAPI delete_file_w(LPCWSTR name) { | |||
| 1117 | removed = true; | 1121 | removed = true; |
| 1118 | } | 1122 | } |
| 1119 | } | 1123 | } |
| 1120 | if (!removed) { | 1124 | if (!removed) return fail_bool(missing_error(r, parts)); |
| 1121 | SetLastError(ERROR_FILE_NOT_FOUND); | ||
| 1122 | return FALSE; | ||
| 1123 | } | ||
| 1124 | return TRUE; | 1125 | return TRUE; |
| 1125 | } | 1126 | } |
| 1126 | 1127 | ||
| @@ -1209,7 +1210,7 @@ BOOL WINAPI remove_directory_w(LPCWSTR name) { | |||
| 1209 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); | 1210 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); |
| 1210 | if (drive_root(name, parts)) return fail_bool(ERROR_ACCESS_DENIED); // "GAME:" and "T:" themselves stay | 1211 | if (drive_root(name, parts)) return fail_bool(ERROR_ACCESS_DENIED); // "GAME:" and "T:" themselves stay |
| 1211 | const View v = view(r, parts); | 1212 | const View v = view(r, parts); |
| 1212 | if (v.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND); | 1213 | if (v.kind == Kind::None) return fail_bool(missing_error(r, parts)); |
| 1213 | if (v.kind == Kind::File) return fail_bool(ERROR_DIRECTORY); | 1214 | if (v.kind == Kind::File) return fail_bool(ERROR_DIRECTORY); |
| 1214 | if (!empty_in_view(r, parts)) return fail_bool(ERROR_DIR_NOT_EMPTY); | 1215 | if (!empty_in_view(r, parts)) return fail_bool(ERROR_DIR_NOT_EMPTY); |
| 1215 | 1216 | ||
| @@ -1246,7 +1247,7 @@ BOOL WINAPI move_file_ex_w(LPCWSTR from, LPCWSTR to, DWORD flags) { | |||
| 1246 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); | 1247 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); |
| 1247 | if (drive_root(from, src) || drive_root(to, dst)) return fail_bool(ERROR_ACCESS_DENIED); | 1248 | if (drive_root(from, src) || drive_root(to, dst)) return fail_bool(ERROR_ACCESS_DENIED); |
| 1248 | const View from_view = view(r, src); | 1249 | const View from_view = view(r, src); |
| 1249 | if (from_view.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND); | 1250 | if (from_view.kind == Kind::None) return fail_bool(missing_error(r, src)); |
| 1250 | const std::filesystem::path overlay_from = disk_path(r.overlay, src), overlay_to = disk_path(r.overlay, dst); | 1251 | const std::filesystem::path overlay_from = disk_path(r.overlay, src), overlay_to = disk_path(r.overlay, dst); |
| 1251 | if (same_entry(src, dst)) { | 1252 | if (same_entry(src, dst)) { |
| 1252 | // The destination is the source, so it is not "already there". The host succeeds at a move onto the same | 1253 | // The destination is the source, so it is not "already there". The host succeeds at a move onto the same |
| @@ -1497,7 +1498,7 @@ BOOL WINAPI set_file_attributes_w(LPCWSTR name, DWORD attributes) { | |||
| 1497 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); | 1498 | if (r.game.empty() || r.overlay.empty()) return fail_bool(ERROR_PATH_NOT_FOUND); |
| 1498 | if (parts.empty()) return fail_bool(ERROR_ACCESS_DENIED); | 1499 | if (parts.empty()) return fail_bool(ERROR_ACCESS_DENIED); |
| 1499 | const View v = view(r, parts); | 1500 | const View v = view(r, parts); |
| 1500 | if (v.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND); | 1501 | if (v.kind == Kind::None) return fail_bool(missing_error(r, parts)); |
| 1501 | 1502 | ||
| 1502 | // The attributes belong to the overlay copy: a package file is copied up and a package folder mirrored first, | 1503 | // The attributes belong to the overlay copy: a package file is copied up and a package folder mirrored first, |
| 1503 | // so the package keeps its own attributes and reads, which prefer the overlay, see the new ones. | 1504 | // so the package keeps its own attributes and reads, which prefer the overlay, see the new ones. |