Skip to content

file_system: a read of a missing name in an overlay-only folder is ERROR_FILE_NOT_FOUND - #8206

Open
Maraco91 wants to merge 2 commits into
ItsNotRexed:mainfrom
Maraco91:fix/file-system-read-missing-name-overlay-folder
Open

Maraco91 wants to merge 2 commits into
ItsNotRexed:mainfrom
Maraco91:fix/file-system-read-missing-name-overlay-folder

Conversation

@Maraco91

Copy link
Copy Markdown

Claim: #8047 (comment)

@ItsNotRexed: an exe PR, as you asked.

What

A read of a missing name in a folder that only the overlay has now fails with ERROR_FILE_NOT_FOUND (2) instead of ERROR_PATH_NOT_FOUND (3).

read_target (runtime/shims/file_system.cpp) hands a name the overlay lacks to the package path and lets the host answer. For a folder only the overlay has, the package has no such folder, so the host reports the folder as missing. That covers:

  • all of T:\ (the scratch folder lives in the overlay as .gta6rt-temp), and
  • any folder the title made under GAME:\.

read_target now uses the overlay path when the name's folder is a folder in the overlay and is not in the package. Everything else still goes to the package path. The change is inside read_target only, so it reaches its callers: a read-open (CreateFileA/W, CreateFile2), GetFileAttributes(Ex)A/W, the CopyFile* source and the CreateDirectoryEx template.

Why

On Windows a missing name in an existing folder is ERROR_FILE_NOT_FOUND; ERROR_PATH_NOT_FOUND means the folder itself is missing. The test checks both on a host temp folder. The shim also disagreed with itself: a write-open of the same missing name on T:\ already answered 2.

A title that probes its scratch drive before first use ("is my cache file there yet?") and treats only error 2 as "not there yet" takes its error path on 3. Whether the retail executable makes that distinction is not measured here: I did not read the executable, and no report in #7154 names this call. The CRT and std::filesystem fold 2 and 3 together, so only direct Win32 checks see the difference.

Separate from #7316 (the opposite direction, 2 → 3, for delete / remove / set-attributes / move source; it does not touch read_target), #7672 (the T:\ root) and #3532 (creating opens).

Tested

Windows 11 (10.0.26200), MSVC 19.42 (VS 2022 Build Tools), RelWithDebInfo, NTFS. No GPU involved, no game files.

cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON
cmake --build runtime/build --target file_system_test
runtime/build/file_system_test.exe
  • Before (the new test on main@dde82f27e's file_system.cpp): 456 check(s), 3 failure(s), exit 1:
    • FAIL a missing name on T:\ is ERROR_FILE_NOT_FOUND for GetFileAttributesW and a read-open
    • FAIL and in a folder of T:\
    • FAIL a missing name in a folder the title made is ERROR_FILE_NOT_FOUND
  • After: 456 check(s), 0 failure(s), exit 0.
  • Negative controls, passing before and after:
    • a missing folder is still ERROR_PATH_NOT_FOUND, on T:\nodir\… and GAME:\nodir\…;
    • a missing name in a package folder is still ERROR_FILE_NOT_FOUND;
    • a package file in a folder the overlay also has still reads from the package;
    • a write-open (OPEN_EXISTING) of the missing name on T: answers ERROR_FILE_NOT_FOUND;
    • the failed reads leave nothing behind in the overlay;
    • the host reference: 2 for a missing name, 3 for a missing folder.
  • The other targets that compile file_system.cpp still pass: xgameruntime_test (143 checks), xgameruntime_gamesave_test (56), xgameruntime_store_test (24), xgameruntime_offline_test (44), xgameruntime_user_test (42).
  • python -I scripts/check_no_game_data.py on the two changed files: exit 0.

Not tested: Linux/Wine, and no boot of the title.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Maraco91 and others added 2 commits November 23, 2026 19:12
…ROR_FILE_NOT_FOUND

read_target handed a name the overlay lacks to the package path. For a
folder only the overlay has (all of T:\, and any folder the title made
under GAME:\) the package has no such folder, so GetFileAttributes and a
read-open failed with ERROR_PATH_NOT_FOUND where Windows answers
ERROR_FILE_NOT_FOUND for a missing name in an existing folder, and where
a write-open of the same name already answered ERROR_FILE_NOT_FOUND.

The overlay path is used when the folder is in the overlay and not in the
package. file_system_test compares with the host and keeps the missing
folder, package folder and package file cases as they were.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ILE_NOT_FOUND

The control the read-open fix is compared with: it passes before and
after the change in read_target.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant