Skip to content

file_system: GetTempPath and GetTempFileName resolve GAME:, G: and T: to the overlay scratch folder - #8813

Closed
tedin7 wants to merge 5 commits into
ProjectLeonida:mainfrom
tedin7:c2-fs-temp-path-and-filename
Closed

tedin7 wants to merge 5 commits into
ProjectLeonida:mainfrom
tedin7:c2-fs-temp-path-and-filename

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

Route GetTempPathA/W and GetTempFileNameA/W for console paths to the overlay scratch directory. Pass host paths through and let the host implement temporary-file naming semantics.

Why

On the tested Wine host, GAME:\ is expanded into a host path and G:\ and T:\ remain drive paths; GetTempFileNameW fails for each. Temporary files must stay in the overlay.

Tested

  • AI-assisted; synthetic data only. No GPU required.
  • p2, Wine, file_system_test, origin/main with the same test: 460 checks, 15 failures; nine are the new checks, six concern existing MAXIMUM_ALLOWED behavior.
  • p2, Wine, file_system_test, review regression before the fix: 466 checks, 11 failures; five new subdirectory checks fail and the six existing MAXIMUM_ALLOWED failures remain.
  • p2, Wine, file_system_test, with the fix: 467 checks, 6 failures; all seven review checks pass, including TEMP fallback and refused path. The same six MAXIMUM_ALLOWED failures remain; the complete test is not green.
  • p2, Wine, file_system_test, Unicode path review: 468 checks, 6 existing MAXIMUM_ALLOWED failures; the new regression fails before the fix and passes after it.
  • p2, Wine, file_system_test, GetTempPathA Unicode review: 469 checks, 6 existing MAXIMUM_ALLOWED failures; the new check fails before the fix and passes after it.
  • p2, Wine, file_system_test, GetTempPathA exact-capacity review: 470 checks, 6 existing MAXIMUM_ALLOWED failures; the new boundary and sentinel check passes.
  • Linux portable runtime build and ctest: 62 passed, 2 skipped, 0 failed (64 total).
  • python -I scripts/check_no_game_data.py runtime/shims/file_system.cpp runtime/test/file_system_test.cpp passed.

@ItsNotRexed: an exe PR, as you asked.

Claim: #8683 (comment)

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Windows 11.

  • Properly routes console temporary directory paths (\T:\..., \GAME:\...) to the writable overlay scratch folder (
    oots().overlay / kScratchDir):
    • Implements \GetTempPathW, \GetTempPathA, \GetTempFileNameW, and \GetTempFileNameA.
    • Preserves sub-path components and strips the drive token for \Drive::Scratch.
    • Non-console paths pass through transparently to the Win32 host APIs.
    • Proper error propagation and \ERROR_PATH_NOT_FOUND\ normalization when the scratch directory is missing.
  • Contract unit tests in
    untime/test/file_system_test.cpp\ cover console temp routing, overlay isolation, and error scenarios.
  • Clean-room check and \git diff --check\ pass.

LGTM!

@lohant27-netizen

Copy link
Copy Markdown

Tested bad1bbaac on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8815, #8814, #8809, #8784, #8783 and #8813 (no conflicts): pass.

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified head da3f48481 merged onto main (867d922f0) on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo):

  • python -I scripts/check_no_game_data.py on both changed files: clean (exit 0)
  • cmake --build runtime/build --target file_system_test --parallel: built cleanly
  • ctest --test-dir runtime/build -R '^file_system$' --output-on-failure -V: 1/1 passed (470 check(s), 0 failure(s))

AI-assisted.

@philip-roy-jones

Copy link
Copy Markdown

I compared the return counts from GetTempPathA/W with native Win32 at 33844680 using a process with UTF-8 as its active code page (GetACP() == 65001). One of 16 paired calls differed. For a synthetic temp path ending in café\, the ANSI path was 90 bytes plus one byte for NUL.

ANSI buffer capacity Win32 return Shim return
0 91 91
90 90 91
91 90 90
260 90 90

The exact-size and larger buffers contained the same complete path and terminator. The ASCII control and all wide-character return counts agreed. I repeated the same matrix on da3f4848 and 33844680 with the same directories. All 32 individual return counts stayed the same across the two revisions.

This measures a representable UTF-8 path on Windows 11 x64 build 26200.9974. CPU-only, synthetic directories. AI-assisted (Codex).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the exact-capacity matrix. Fixed in eb6133c30: GetTempPathA with a buffer exactly as long as the path (no room for the NUL) now returns the path length like Win32 (90 in your table); capacity 0 and all other cases are unchanged, and the test has the new case. file_system_test on p2/Wine: 470 checks, only the 6 MAXIMUM_ALLOWED failures that main already has.

@ddaikodaiko

Copy link
Copy Markdown

Windows check of eb6133c: Windows 10 Pro 10.0.19045, MSVC 19.44.35229, Windows SDK 10.0.26100, CMake 3.31 + Ninja, Python 3.14.3. No game files.

cmake --build runtime\build --target file_system_test -j 10
ctest --test-dir runtime\build -R "^file_system$" --output-on-failure
1/1 Test #51: file_system ......................   Passed    2.33 sec

The GetTempPath/G:/T: cases (including the exact-capacity return this commit fixes) pass against the editor's overlay on Windows 10.

@SpaghettiMaster545

Copy link
Copy Markdown

Tested eb6133c30 merged onto main 5d74c2723 (clean merge) on Windows 11 IoT Enterprise LTSC 2024 (26100), active code page 1250, MSVC 14.50 (VS 2026) RelWithDebInfo + Ninja, NVIDIA GeForce RTX 5070 Ti (621.24). Synthetic tests only, no game files.

Pass. AI-assisted (Claude Code).

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.

8 participants