From e8512cf4c1b15a8d469e8c1846df57ad619d1f1a Mon Sep 17 00:00:00 2001 From: Duff <19514584+Dufftwt@users.noreply.github.com> Date: Tue, 24 Nov 2026 01:43:55 +0100 Subject: [PATCH] Files: a title run by its file name alone gets its own folder as G: `victory run GTA6.exe`, run from the game folder, gives an exe path with an empty parent, and that empty folder was mounted as G:. An empty path cannot be made absolute, so the root stayed empty and G:\x64\a.rpf became \x64\a.rpf: the root of the current drive. The title then found none of its files. An empty root is now the current directory, which is what an empty folder means everywhere else (`Path::new("").join("x")` is `x` in the current directory). Passing a path with a folder in it is unaffected. (cherry picked from commit 01ae55a3ba04c39a0e8851cc00da16af7a49adbd) --- crates/viport-hle/src/modules/files.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/viport-hle/src/modules/files.rs b/crates/viport-hle/src/modules/files.rs index 7709784d..afaa2e7b 100644 --- a/crates/viport-hle/src/modules/files.rs +++ b/crates/viport-hle/src/modules/files.rs @@ -84,8 +84,15 @@ pub fn mount_at(letter: char, root: &Path) { } /// `root` as UTF-16, absolute, without trailing separators (a drive root -/// keeps its own). +/// keeps its own). An empty root is the current directory, as it is to a +/// path joined to it: it is the title's folder when the title is run by its +/// file name alone (`victory run GTA6.exe`). fn root_wide(root: &Path) -> Vec { + let root = if root.as_os_str().is_empty() { + Path::new(".") + } else { + root + }; let root = std::path::absolute(root).unwrap_or_else(|_| root.to_owned()); let mut wide: Vec = root.as_os_str().encode_wide().collect(); while wide.len() > 3 && wide.last().is_some_and(|c| SEPARATORS.contains(c)) { @@ -815,6 +822,17 @@ mod tests { ); } + /// A title run by its file name alone has an empty folder: the drive + /// over it is the current directory, not the current drive's root. + #[test] + fn an_empty_root_is_the_current_directory() { + let letter = mount(Path::new("")).unwrap(); + let path = format!(r"{letter}:\a.rpf"); + let host = translate(&w(&path)[..path.len()]).map(|v| text(&v)); + let cwd = std::env::current_dir().unwrap(); + assert_eq!(host, Some(cwd.join("a.rpf").display().to_string())); + } + #[test] fn long_title_paths_work_on_the_host() { let dir = tempfile::tempdir().unwrap();