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/test/file_system_test.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/test/file_system_test.cpp')
| -rw-r--r-- | runtime/test/file_system_test.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/runtime/test/file_system_test.cpp b/runtime/test/file_system_test.cpp index 7b68d0c69..fcc45d4fb 100644 --- a/runtime/test/file_system_test.cpp +++ b/runtime/test/file_system_test.cpp | |||
| @@ -628,8 +628,8 @@ void run_checks(const std::filesystem::path& root) { | |||
| 628 | check(delete_w(L"GAME:\\data\\bye.txt") == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND, | 628 | check(delete_w(L"GAME:\\data\\bye.txt") == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND, |
| 629 | "deleting an already hidden file reports ERROR_FILE_NOT_FOUND"); | 629 | "deleting an already hidden file reports ERROR_FILE_NOT_FOUND"); |
| 630 | SetLastError(0); | 630 | SetLastError(0); |
| 631 | check(delete_w(L"GAME:\\nope\\missing.txt") == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND, | 631 | check(delete_w(L"GAME:\\nope\\missing.txt") == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, |
| 632 | "deleting a file that never existed reports ERROR_FILE_NOT_FOUND"); | 632 | "deleting a file in a folder that never existed reports ERROR_PATH_NOT_FOUND"); |
| 633 | 633 | ||
| 634 | // Deleting a nested package file creates parent directories inside .gta6rt-deleted/; those marker parent | 634 | // Deleting a nested package file creates parent directories inside .gta6rt-deleted/; those marker parent |
| 635 | // directories must not hide the corresponding ancestor directories in the package. | 635 | // directories must not hide the corresponding ancestor directories in the package. |
| @@ -845,6 +845,49 @@ void run_checks(const std::filesystem::path& root) { | |||
| 845 | "and the new folder is empty: only . and .."); | 845 | "and the new folder is empty: only . and .."); |
| 846 | } | 846 | } |
| 847 | 847 | ||
| 848 | { | ||
| 849 | const std::filesystem::path host = root / "host_missing"; | ||
| 850 | write_path(host / "file.txt", "file"); | ||
| 851 | const std::wstring host_dest = (host / "dest.txt").wstring(); | ||
| 852 | auto error_of = [](BOOL ok) { return ok ? DWORD{0} : GetLastError(); }; | ||
| 853 | struct Name { | ||
| 854 | const wchar_t* game; | ||
| 855 | std::filesystem::path host; | ||
| 856 | DWORD expected; | ||
| 857 | const char* what; | ||
| 858 | }; | ||
| 859 | const Name names[] = { | ||
| 860 | {L"GAME:\\nowhere\\x.txt", host / "nowhere" / "x.txt", ERROR_PATH_NOT_FOUND, "inside a missing folder"}, | ||
| 861 | {L"GAME:\\misc\\keep.txt\\x.txt", host / "file.txt" / "x.txt", ERROR_PATH_NOT_FOUND, "below a file"}, | ||
| 862 | {L"GAME:\\misc\\absent.txt", host / "absent.txt", ERROR_FILE_NOT_FOUND, "missing from a folder that exists"}, | ||
| 863 | }; | ||
| 864 | for (const Name& n : names) { | ||
| 865 | const std::wstring native = n.host.wstring(); | ||
| 866 | const std::string suffix = std::string(" of a name ") + n.what + " fails as on the host"; | ||
| 867 | SetLastError(0); | ||
| 868 | const DWORD host_delete = error_of(::DeleteFileW(native.c_str())); | ||
| 869 | SetLastError(0); | ||
| 870 | check(error_of(delete_w(n.game)) == n.expected && host_delete == n.expected, ("DeleteFileW" + suffix).c_str()); | ||
| 871 | SetLastError(0); | ||
| 872 | const DWORD host_rmdir = error_of(::RemoveDirectoryW(native.c_str())); | ||
| 873 | SetLastError(0); | ||
| 874 | check(error_of(rmdir_w(n.game)) == n.expected && host_rmdir == n.expected, | ||
| 875 | ("RemoveDirectoryW" + suffix).c_str()); | ||
| 876 | SetLastError(0); | ||
| 877 | const DWORD host_setattr = error_of(::SetFileAttributesW(native.c_str(), FILE_ATTRIBUTE_NORMAL)); | ||
| 878 | SetLastError(0); | ||
| 879 | check(error_of(setattr_w(n.game, FILE_ATTRIBUTE_NORMAL)) == n.expected && host_setattr == n.expected, | ||
| 880 | ("SetFileAttributesW" + suffix).c_str()); | ||
| 881 | SetLastError(0); | ||
| 882 | const DWORD host_move = error_of(::MoveFileExW(native.c_str(), host_dest.c_str(), MOVEFILE_REPLACE_EXISTING)); | ||
| 883 | SetLastError(0); | ||
| 884 | check(error_of(move_ex_w(n.game, L"GAME:\\misc\\dest.txt", MOVEFILE_REPLACE_EXISTING)) == n.expected && | ||
| 885 | host_move == n.expected, | ||
| 886 | ("MoveFileExW" + suffix).c_str()); | ||
| 887 | } | ||
| 888 | check(!std::filesystem::exists(overlay / "nowhere") && !std::filesystem::exists(overlay / "misc" / "dest.txt"), | ||
| 889 | "and none of them leaves anything in the overlay"); | ||
| 890 | } | ||
| 848 | // Recreating a removed package directory clears its own marker, but not nested deletion markers. | 891 | // Recreating a removed package directory clears its own marker, but not nested deletion markers. |
| 849 | { | 892 | { |
| 850 | std::filesystem::create_directories(package / "recreate_dir"); | 893 | std::filesystem::create_directories(package / "recreate_dir"); |