diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-23 17:07:57 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-23 17:07:57 -0500 |
| commit | dea8ce204d946c7a2e831200e1b24c8d7e4b8ab9 (patch) | |
| tree | 816b18d624e6d434c730c57a95c677b03449de0f /runtime/test/file_system_test.cpp | |
| parent | 14773047f55b824aa977e610d1c2f7653b67ec5c (diff) | |
| parent | 6de6f5b2bb126a4596bd8ac813c0422435587ae6 (diff) | |
Merge PR #9567
Diffstat (limited to 'runtime/test/file_system_test.cpp')
| -rw-r--r-- | runtime/test/file_system_test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/runtime/test/file_system_test.cpp b/runtime/test/file_system_test.cpp index 0a0ab76c5..73665411f 100644 --- a/runtime/test/file_system_test.cpp +++ b/runtime/test/file_system_test.cpp | |||
| @@ -709,6 +709,45 @@ void run_checks(const std::filesystem::path& root) { | |||
| 709 | "and the new folder is empty: only . and .."); | 709 | "and the new folder is empty: only . and .."); |
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | // Recreating a removed package directory clears its own marker, but not nested deletion markers. | ||
| 713 | { | ||
| 714 | std::filesystem::create_directories(package / "recreate_dir"); | ||
| 715 | const auto mark = overlay / ".gta6rt-deleted" / "recreate_dir" / ".gta6rt-dir"; | ||
| 716 | check(rmdir_w(L"GAME:\\recreate_dir") != FALSE && std::filesystem::exists(mark), | ||
| 717 | "removing a package directory creates its marker"); | ||
| 718 | check(mkdir_w(L"GAME:\\recreate_dir", nullptr) != FALSE, "recreating the package directory succeeds"); | ||
| 719 | const DWORD attrs = attributes_w(L"GAME:\\recreate_dir"); | ||
| 720 | check(attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY), "recreated directory has directory attributes"); | ||
| 721 | check(count(list(first_w, next_w, find_close, L"GAME:\\*"), L"recreate_dir") == 1, | ||
| 722 | "recreated directory is listed once"); | ||
| 723 | check(!std::filesystem::exists(mark), "recreated directory has no removal marker"); | ||
| 724 | check(mkdir_w(L"GAME:\\never_removed_dir", nullptr) != FALSE && | ||
| 725 | std::filesystem::is_directory(overlay / "never_removed_dir") && | ||
| 726 | !std::filesystem::exists(overlay / ".gta6rt-deleted" / "never_removed_dir"), | ||
| 727 | "creating a never-removed directory is unchanged"); | ||
| 728 | } | ||
| 729 | |||
| 730 | // A marker held without delete sharing makes recreation fail and rolls back the overlay directory. | ||
| 731 | { | ||
| 732 | std::filesystem::create_directories(package / "held_marker_dir"); | ||
| 733 | const auto mark = overlay / ".gta6rt-deleted" / "held_marker_dir" / ".gta6rt-dir"; | ||
| 734 | check(rmdir_w(L"GAME:\\held_marker_dir") != FALSE, "removing the directory creates a marker to hold"); | ||
| 735 | const HANDLE held = ::CreateFileW(mark.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, | ||
| 736 | FILE_ATTRIBUTE_NORMAL, nullptr); | ||
| 737 | check(held != INVALID_HANDLE_VALUE, "opened the removal marker without delete sharing"); | ||
| 738 | if (held != INVALID_HANDLE_VALUE) { | ||
| 739 | const BOOL created = mkdir_w(L"GAME:\\held_marker_dir", nullptr); | ||
| 740 | const DWORD error = GetLastError(); | ||
| 741 | check(!created && (error == ERROR_SHARING_VIOLATION || error == ERROR_ACCESS_DENIED), | ||
| 742 | "recreating a directory reports the marker deletion error"); | ||
| 743 | check(!std::filesystem::exists(overlay / "held_marker_dir") && std::filesystem::exists(mark), | ||
| 744 | "failed recreation removes the overlay directory and keeps the marker"); | ||
| 745 | ::CloseHandle(held); | ||
| 746 | check(mkdir_w(L"GAME:\\held_marker_dir", nullptr) != FALSE, | ||
| 747 | "recreating the directory succeeds after releasing the marker"); | ||
| 748 | } | ||
| 749 | } | ||
| 750 | |||
| 712 | // MoveFile: the destination is in the overlay; a moved package file is deleted by a marker. | 751 | // MoveFile: the destination is in the overlay; a moved package file is deleted by a marker. |
| 713 | { | 752 | { |
| 714 | check(move_w(L"GAME:\\misc\\one.txt", L"GAME:\\misc\\moved.txt") != FALSE, "MoveFileW moves a package file"); | 753 | check(move_w(L"GAME:\\misc\\one.txt", L"GAME:\\misc\\moved.txt") != FALSE, "MoveFileW moves a package file"); |