diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 22:09:51 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 22:12:50 -0500 |
| commit | be8570ace18d3144d6cbfc2d57c60e736a1c1465 (patch) | |
| tree | 2aa5c100fb9b4ec22b819333194baeea5d3b7906 /runtime/test/file_system_test.cpp | |
| parent | f99ff6cbdd23a2417af5494497f2f23da67c144a (diff) | |
| parent | d0835dd9f9ec0a88faee510126436f2427854c2e (diff) | |
Merge remote-tracking branch 'origin/main' into triage-r43
# Conflicts:
# docs/runtime_imports.md
# runtime/CMakeLists.txt
# runtime/shims/xgameruntime.cpp
# runtime/test/xmem_test.cpp
# tools/rdna2spirv.py
Diffstat (limited to 'runtime/test/file_system_test.cpp')
| -rw-r--r-- | runtime/test/file_system_test.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/runtime/test/file_system_test.cpp b/runtime/test/file_system_test.cpp index 21f9c8d10..58233ee98 100644 --- a/runtime/test/file_system_test.cpp +++ b/runtime/test/file_system_test.cpp | |||
| @@ -688,6 +688,62 @@ int main() { | |||
| 688 | "the copy staging folder is hidden from a GAME: listing"); | 688 | "the copy staging folder is hidden from a GAME: listing"); |
| 689 | } | 689 | } |
| 690 | 690 | ||
| 691 | // RT-218: "G:\" is the package and "T:\" a writable scratch folder in the overlay, as in the other console layers. | ||
| 692 | // A host path under the configured folders stays a host path, and a path that climbs out of the drive is refused. | ||
| 693 | { | ||
| 694 | write_path(package / "drives" / "sub" / "probe.txt", "probe"); | ||
| 695 | HANDLE h = create_w(L"G:\\drives\\sub\\probe.txt", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); | ||
| 696 | check(h != INVALID_HANDLE_VALUE && read_handle(h) == "probe", "CreateFileW opens G:\\drives\\sub\\probe.txt from the package"); | ||
| 697 | if (h != INVALID_HANDLE_VALUE) ::CloseHandle(h); | ||
| 698 | h = create_w(L"g:/drives/sub/probe.txt", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); | ||
| 699 | check(h != INVALID_HANDLE_VALUE, "the drive letter is case-insensitive and accepts forward slashes"); | ||
| 700 | if (h != INVALID_HANDLE_VALUE) ::CloseHandle(h); | ||
| 701 | check(attributes_w(L"G:\\data\\sub") != INVALID_FILE_ATTRIBUTES, "GetFileAttributesW stats a G: folder"); | ||
| 702 | |||
| 703 | SetLastError(0); | ||
| 704 | check(create_w(L"G:\\..\\x.txt", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr) == | ||
| 705 | INVALID_HANDLE_VALUE && | ||
| 706 | GetLastError() == ERROR_INVALID_NAME, | ||
| 707 | "G:\\.. is refused with ERROR_INVALID_NAME"); | ||
| 708 | |||
| 709 | h = create_w(L"T:\\cache\\scratch.bin", GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr); | ||
| 710 | check(h != INVALID_HANDLE_VALUE, "CreateFileW creates a file on T: (parent folders and all)"); | ||
| 711 | if (h != INVALID_HANDLE_VALUE) { | ||
| 712 | DWORD written = 0; | ||
| 713 | ::WriteFile(h, "scratch", 7, &written, nullptr); | ||
| 714 | ::CloseHandle(h); | ||
| 715 | } | ||
| 716 | check(read_path(overlay / ".gta6rt-temp" / "cache" / "scratch.bin") == "scratch", | ||
| 717 | "a T: file lands in the overlay's scratch folder"); | ||
| 718 | check(!std::filesystem::exists(package / "cache" / "scratch.bin") && !std::filesystem::exists(package / ".gta6rt-temp"), | ||
| 719 | "and the package is untouched"); | ||
| 720 | h = create_w(L"t:/cache/scratch.bin", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); | ||
| 721 | check(h != INVALID_HANDLE_VALUE && read_handle(h) == "scratch", "the T: file reads back"); | ||
| 722 | if (h != INVALID_HANDLE_VALUE) ::CloseHandle(h); | ||
| 723 | check(attributes_w(L"GAME:\\cache\\scratch.bin") == INVALID_FILE_ATTRIBUTES, | ||
| 724 | "T: is its own drive: GAME: does not see the scratch file"); | ||
| 725 | check(!contains(list(first_w, next_w, find_close, L"GAME:\\*"), L".gta6rt-temp"), | ||
| 726 | "a listing of GAME:\\ does not show the scratch folder"); | ||
| 727 | SetLastError(0); | ||
| 728 | check(create_w(L"T:\\..\\data\\hello.txt", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr) == | ||
| 729 | INVALID_HANDLE_VALUE && | ||
| 730 | GetLastError() == ERROR_INVALID_NAME, | ||
| 731 | "T:\\.. cannot climb out of the scratch folder into the package"); | ||
| 732 | |||
| 733 | // A package that itself sits on drive G: is reached by host paths, which must stay host paths. | ||
| 734 | rt::fs::configure(L"G:\\leonida_missing_package", L"G:\\leonida_missing_overlay"); | ||
| 735 | SetLastError(0); | ||
| 736 | check(attributes_w(L"G:\\leonida_missing_package\\data.txt") == INVALID_FILE_ATTRIBUTES && | ||
| 737 | GetLastError() != ERROR_INVALID_NAME, | ||
| 738 | "a path under a configured G: game folder is a host path"); | ||
| 739 | // No roots configured: nothing to map G: and T: onto, so they are host paths. | ||
| 740 | rt::fs::configure({}, {}); | ||
| 741 | SetLastError(0); | ||
| 742 | check(attributes_w(L"T:\\x") == INVALID_FILE_ATTRIBUTES && GetLastError() != ERROR_INVALID_NAME, | ||
| 743 | "without configured folders G: and T: stay host drives"); | ||
| 744 | rt::fs::configure(package, overlay); | ||
| 745 | } | ||
| 746 | |||
| 691 | std::filesystem::remove_all(root); | 747 | std::filesystem::remove_all(root); |
| 692 | std::printf("%d check(s), %d failure(s)\n", g_checks, g_failures); | 748 | std::printf("%d check(s), %d failure(s)\n", g_checks, g_failures); |
| 693 | return g_failures == 0 ? 0 : 1; | 749 | return g_failures == 0 ? 0 : 1; |