Skip to content

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

Open
reeledMarek wants to merge 1 commit into
Marvisak:mainfrom
reeledMarek:fix/hle-files-verbatim-and-disk-free-space
Open

reeledMarek wants to merge 1 commit into
Marvisak:mainfrom
reeledMarek:fix/hle-files-verbatim-and-disk-free-space

Conversation

@reeledMarek

Copy link
Copy Markdown
Contributor

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

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

@fuzeofficlal fuzeofficlal 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.

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.

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.

3 participants