fix(hle): fix verbatim/UNC/drive-root virtual path translation and GetDiskFreeSpaceW volume roots #3361

Open
github-bot wants to merge 2 commits from github-bot/gh-3361 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-26 20:25 UTC · original
reeledMarek:fix/hle-files-verbatim-and-disk-free-space → main · +172 −32 · 1 files · 2 commits · open

Summary

  • When a title passed a \\?\ verbatim virtual-drive path (e.g. \\?\G:\...), translate blindly prepended \\?\ to the mounted host root, producing invalid paths for UNC mounts (\\?\\\server\share\... instead of \\?\UNC\server\share\...), already-verbatim mounts (\\?\\\?\...), and drive-root mounts (\\?\D:\\foo or D:\\foo).
  • Factors verbatim_root and join_host_path so verbatim, UNC, and drive-root mounts join cleanly without duplicate prefixes or doubled backslashes.
  • Extracts volume_root for GetDiskFreeSpaceW so \\?\C:\..., \\?\UNC\server\share\..., and \\server\share\... translated host paths are trimmed to a valid volume root instead of passing a subdirectory.
  • Adds unit tests verbatim_and_drive_root_mounts_join_cleanly and volume_root_handles_drive_verbatim_and_unc_paths.

Verification

  • cargo clippy -p victory-hle --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • cargo test -p xtask --locked
**@⁠reeledMarek** on GitHub · 2026-11-26 20:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3361) `reeledMarek:fix/hle-files-verbatim-and-disk-free-space` → `main` · +172 −32 · 1 files · 2 commits · open ### Summary - When a title passed a `\\?\` verbatim virtual-drive path (e.g. `\\?\G:\...`), `translate` blindly prepended `\\?\` to the mounted host `root`, producing invalid paths for UNC mounts (`\\?\\\server\share\...` instead of `\\?\UNC\server\share\...`), already-verbatim mounts (`\\?\\\?\...`), and drive-root mounts (`\\?\D:\\foo` or `D:\\foo`). - Factors `verbatim_root` and `join_host_path` so verbatim, UNC, and drive-root mounts join cleanly without duplicate prefixes or doubled backslashes. - Extracts `volume_root` for `GetDiskFreeSpaceW` so `\\?\C:\...`, `\\?\UNC\server\share\...`, and `\\server\share\...` translated host paths are trimmed to a valid volume root instead of passing a subdirectory. - Adds unit tests `verbatim_and_drive_root_mounts_join_cleanly` and `volume_root_handles_drive_verbatim_and_unc_paths`. ### Verification - `cargo clippy -p victory-hle --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` - `cargo test -p xtask --locked`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:26:26 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 20:27 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Handling verbatim (\\?\), UNC (\\?\UNC\... / \\server\share), and drive-root mounts cleanly in virtual path translation and GetDiskFreeSpaceW volume root extraction is well-tested and avoids malformed path joins.
  • cargo test -p victory-hle --lib modules::files:: -- --test-threads=1: 8 passed, 0 failed (including verbatim_and_drive_root_mounts_join_cleanly and volume_root_handles_drive_verbatim_and_unc_paths).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 20:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3361#pullrequestreview-6080153870) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Handling verbatim (`\\?\`), UNC (`\\?\UNC\...` / `\\server\share`), and drive-root mounts cleanly in virtual path translation and `GetDiskFreeSpaceW` volume root extraction is well-tested and avoids malformed path joins. - `cargo test -p victory-hle --lib modules::files:: -- --test-threads=1`: 8 passed, 0 failed (including `verbatim_and_drive_root_mounts_join_cleanly` and `volume_root_handles_drive_verbatim_and_unc_paths`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 20:54 UTC · original · approved these changes

LGTM — verbatim_root, join_host_path, and volume_root cleanly resolve the \?\, \?\UNC\, and drive-root joining edge cases and extract volume roots for GetDiskFreeSpaceW.

Verified

  • cargo run --locked -p xtask -- policy: 191 files ok.
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings (default & --all-features): clean.
  • cargo test --locked -p victory-hle --lib modules::files:: -- --test-threads=1: 8 passed, 0 failed (including verbatim_and_drive_root_mounts_join_cleanly and volume_root_handles_drive_verbatim_and_unc_paths).
  • cargo test --locked -p victory-hle --all-targets -- --test-threads=1: 154 lib + 2 integration tests passed, 0 failed.

Minor non-blocking nits

  • crates/victory-hle/src/modules/files.rs:150: if out.last() == Some(&u16::from(b':')) runs after appending parts; guarding it with parts.is_empty() limits the trailing \ strictly to empty-tail drive roots rather than a colon-suffixed guest component.
  • Pre-existing join_host_path behavior (files.rs:164, 179): / -> \ normalization checks !prefix.is_empty() rather than whether out starts with \?\ (so a short non-verbatim guest path on a \?\ mount keeps /), and short non-verbatim paths still rely on Windows path resolution for ...
  • rustfmt --edition 2024 reports one formatting diff in the new test at files.rs:1046.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 20:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/3361#pullrequestreview-6080387540) · **approved these changes** LGTM — `verbatim_root`, `join_host_path`, and `volume_root` cleanly resolve the `\?\`, `\?\UNC\`, and drive-root joining edge cases and extract volume roots for `GetDiskFreeSpaceW`. ### Verified - `cargo run --locked -p xtask -- policy`: `191 files ok`. - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` (default & `--all-features`): clean. - `cargo test --locked -p victory-hle --lib modules::files:: -- --test-threads=1`: **8 passed, 0 failed** (including `verbatim_and_drive_root_mounts_join_cleanly` and `volume_root_handles_drive_verbatim_and_unc_paths`). - `cargo test --locked -p victory-hle --all-targets -- --test-threads=1`: **154 lib + 2 integration tests passed, 0 failed**. ### Minor non-blocking nits - `crates/victory-hle/src/modules/files.rs:150`: `if out.last() == Some(&u16::from(b':'))` runs after appending `parts`; guarding it with `parts.is_empty()` limits the trailing `\` strictly to empty-tail drive roots rather than a colon-suffixed guest component. - Pre-existing `join_host_path` behavior (`files.rs:164, 179`): `/` -> `\` normalization checks `!prefix.is_empty()` rather than whether `out` starts with `\?\` (so a short non-verbatim guest path on a `\?\` mount keeps `/`), and short non-verbatim paths still rely on Windows path resolution for `..`. - `rustfmt --edition 2024` reports one formatting diff in the new test at `files.rs:1046`.
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 21:04 UTC · original

Thanks for the thorough review @⁠fuzeofficlal! Pushed 60296b7 to guard the trailing \ in verbatim() with parts.is_empty() (with a regression test covering both an empty-tail drive root and a colon-suffixed component) and fixed the rustfmt formatting line.

**@⁠reeledMarek** on GitHub · 2026-11-26 21:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/3361#issuecomment-7203362198) Thanks for the thorough review @⁠fuzeofficlal! Pushed `60296b7` to guard the trailing `\` in `verbatim()` with `parts.is_empty()` (with a regression test covering both an empty-tail drive root and a colon-suffixed component) and fixed the `rustfmt` formatting line.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3361/head:github-bot/gh-3361'
git switch 'github-bot/gh-3361'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3361'
git switch 'github-bot/gh-3361'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3361'
git switch 'github-bot/gh-3361'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3361'
git switch 'main'
git merge --squash 'github-bot/gh-3361'
git switch 'main'
git merge --ff-only 'github-bot/gh-3361'
git switch 'main'
git merge 'github-bot/gh-3361'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3361
No description provided.