Files: a title run by its file name alone gets its own folder as G: #133

Merged
Dufftwt merged 1 commit from upstream-pr/133 into main 2026-11-25 00:15:22 +00:00
Dufftwt commented 2026-11-24 00:49:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dufftwt on 2026-11-24T00:49:05Z.


What's wrong

A natural way to start the game is from inside the game folder, giving only the file name:

cd D:\Games\GTA6
victory run GTA6.exe --execute

run.rs takes the title's folder as exe.parent(). For a bare file name that is an empty path, not ., and it gets mounted as the console's G: drive. files.rs makes each mounted folder absolute with std::path::absolute, but an empty path can't be made absolute (it returns an error). The code then falls back to the empty path itself, so G: points at nothing:

title asks for    G:\x64\a.rpf
host path         \x64\a.rpf      <- the root of the current drive, i.e. D:\x64\a.rpf

The game then can't find any of its own files when started this way. Passing a path with a folder in it (victory run D:\Games\GTA6\GTA6.exe, or .\GTA6.exe) works, which makes the failure confusing.

What the fix does

In files.rs, the function that prepares a mounted folder (root_wide) now treats an empty folder as the current directory (.) before making it absolute. This is what an empty folder already means for every other use of it: Path::new("").join("MicrosoftGame.config") is a file in the current directory.

The fix is in files.rs rather than run.rs. That way it covers every caller of mount / mount_at, and it stays clear of #12 and #112, which both edit those lines of run.rs.

How it behaves after the fix

  • victory run GTA6.exe from the game folder mounts that folder as G:, and the title finds its files.
  • Any path with a folder in it behaves exactly as before.

Tests

The new test an_empty_root_is_the_current_directory in files.rs mounts an empty path and checks that X:\a.rpf is rewritten to <current directory>\a.rpf.

I ran cargo test --workspace --no-fail-fast on GitHub's windows-latest with Rust 1.98.1 from rust-toolchain.toml:

  • This PR: the new test passes; victory-hle has 82 passed and 0 failed.
  • The new test alone on main: it fails. G:\a.rpf became \a.rpf, the root of the drive, instead of D:\a\VIctory\VIctory\crates\victory-hle\a.rpf, the current directory on the runner.
  • In both runs the only other failure is victory-gpu's root::tests::host_serialized_blobs_create_root_signatures. It fails the same way on the main this branch starts from, and #36, now merged, fixes it.

Not tested: a run of the game itself.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572034599 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/133). Originally posted by [Dufftwt](https://github.com/Dufftwt) on 2026-11-24T00:49:05Z. --- ## What's wrong A natural way to start the game is from inside the game folder, giving only the file name: ``` cd D:\Games\GTA6 victory run GTA6.exe --execute ``` `run.rs` takes the title's folder as `exe.parent()`. For a bare file name that is an **empty path**, not `.`, and it gets mounted as the console's `G:` drive. `files.rs` makes each mounted folder absolute with `std::path::absolute`, but an empty path can't be made absolute (it returns an error). The code then falls back to the empty path itself, so `G:` points at nothing: ``` title asks for G:\x64\a.rpf host path \x64\a.rpf <- the root of the current drive, i.e. D:\x64\a.rpf ``` The game then can't find any of its own files when started this way. Passing a path with a folder in it (`victory run D:\Games\GTA6\GTA6.exe`, or `.\GTA6.exe`) works, which makes the failure confusing. ## What the fix does In `files.rs`, the function that prepares a mounted folder (`root_wide`) now treats an empty folder as the current directory (`.`) before making it absolute. This is what an empty folder already means for every other use of it: `Path::new("").join("MicrosoftGame.config")` is a file in the current directory. The fix is in `files.rs` rather than `run.rs`. That way it covers every caller of `mount` / `mount_at`, and it stays clear of #12 and #112, which both edit those lines of `run.rs`. ## How it behaves after the fix - `victory run GTA6.exe` from the game folder mounts that folder as `G:`, and the title finds its files. - Any path with a folder in it behaves exactly as before. ## Tests The new test `an_empty_root_is_the_current_directory` in `files.rs` mounts an empty path and checks that `X:\a.rpf` is rewritten to `<current directory>\a.rpf`. I ran `cargo test --workspace --no-fail-fast` on GitHub's `windows-latest` with Rust 1.98.1 from `rust-toolchain.toml`: - **This PR:** the new test passes; `victory-hle` has 82 passed and 0 failed. - **The new test alone on `main`:** it fails. `G:\a.rpf` became `\a.rpf`, the root of the drive, instead of `D:\a\VIctory\VIctory\crates\victory-hle\a.rpf`, the current directory on the runner. - In both runs the only other failure is `victory-gpu`'s `root::tests::host_serialized_blobs_create_root_signatures`. It fails the same way on the `main` this branch starts from, and #36, now merged, fixes it. **Not tested:** a run of the game itself.
jeremygold02 commented 2026-11-24 06:55:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:32:21Z.


Tested head 01ae55a3ba04c39a0e8851cc00da16af7a49adbd with cargo test -p victory-hle --lib files -- --test-threads=1: 7 passed, 0 failed (75 filtered). The five modules::files::tests::* cases cover empty-root fallback, rewriting only mounted-drive paths, long paths, kernel-buffer reads, and title-file calls reaching the host folder (files.rs). This is synthetic unit coverage; no title runtime was launched.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7122110795 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/133#issuecomment-7122110795). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:32:21Z. --- Tested head `01ae55a3ba04c39a0e8851cc00da16af7a49adbd` with `cargo test -p victory-hle --lib files -- --test-threads=1`: **7 passed, 0 failed** (75 filtered). The five `modules::files::tests::*` cases cover empty-root fallback, rewriting only mounted-drive paths, long paths, kernel-buffer reads, and title-file calls reaching the host folder ([`files.rs`](https://github.com/Marvisak/VIctory/blob/01ae55a3ba04c39a0e8851cc00da16af7a49adbd/crates/victory-hle/src/modules/files.rs)). This is synthetic unit coverage; no title runtime was launched.
mercuryVM commented 2026-11-24 07:32:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:32:32Z.

Review: APPROVED


Tested 01ae55a on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (228 passed, 0 failed; the branch is based on an older main), including an_empty_root_is_the_current_directory.

Path::new("").parent()-style empty roots really do fail std::path::absolute, and the old fallback then turned G:\x\y into \x\y, the root of the current drive. Mapping an empty root to . before absolute gives the current directory, which is what exe.parent() meant for a bare file name. Non-empty roots are untouched.

One thing to be aware of: the drive is resolved when it is mounted, so it captures the cwd at that moment. A later SetCurrentDirectory by the title won't move G:. That is what you want here.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035308194 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/133#pullrequestreview-6035308194). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T07:32:32Z. **Review:** APPROVED --- Tested 01ae55a on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (228 passed, 0 failed; the branch is based on an older main), including `an_empty_root_is_the_current_directory`. `Path::new("").parent()`-style empty roots really do fail `std::path::absolute`, and the old fallback then turned `G:\x\y` into `\x\y`, the root of the current drive. Mapping an empty root to `.` before `absolute` gives the current directory, which is what `exe.parent()` meant for a bare file name. Non-empty roots are untouched. One thing to be aware of: the drive is resolved when it is mounted, so it captures the cwd at that moment. A later `SetCurrentDirectory` by the title won't move `G:`. That is what you want here. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:02:45 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!133
No description provided.