Merge pull request #133 from Dufftwt/fix/bare-exe-name-title-folder

Files: a title run by its file name alone gets its own folder as G:
This commit is contained in:
Marvis authored and GitHub committed 2026-11-25 01:15:21 +01:00 Unverified
commit d6e00a85a5
1 file changed
+19 -1
+19 -1
View File
@@ -83,8 +83,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<u16> {
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<u16> = root.as_os_str().encode_wide().collect();
while wide.len() > 3 && wide.last().is_some_and(|c| SEPARATORS.contains(c)) {
@@ -804,6 +811,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();