From e17f6f9b47d2c7d86ebcf694d95f156c7775aa59 Mon Sep 17 00:00:00 2001 From: pickles976 Date: Tue, 24 Nov 2026 03:55:11 +0000 Subject: [PATCH] VFS: a search on the bare mount root lists no entries FindFirstFile("G:\\") passed an empty relative path to collect_game_entries, which then searched the overlay and game host folders themselves and exposed the host directories as title entries. Windows reports no entries for a bare drive root; return ERROR_FILE_NOT_FOUND. Third case of #577 (cases 1 and 2 are #644 and #618). Unit test added. Co-Authored-By: Claude --- crates/xcl/src/vfs_hooks.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/xcl/src/vfs_hooks.rs b/crates/xcl/src/vfs_hooks.rs index 7cf09a9c3..cc2e2b5fb 100644 --- a/crates/xcl/src/vfs_hooks.rs +++ b/crates/xcl/src/vfs_hooks.rs @@ -990,6 +990,13 @@ fn collect_game_entries( rel: &str, collect_fn: impl Fn(&str) -> Vec, ) -> Result, u32> { + if rel.is_empty() { + // FindFirstFile on the bare mount root ("G:\"): the relative path is empty, + // so the search would run on the overlay and game folders themselves and + // list the host directories as game entries. Windows has no entries for a + // bare drive root either: report none. + return Err(vfs::ERROR_FILE_NOT_FOUND); + } let (dir_rel, pattern) = match rel.rsplit_once('\\') { Some((d, p)) => (d.to_string(), p.to_string()), None => (String::new(), rel.to_string()), @@ -1734,4 +1741,13 @@ mod tests { after.sort(); assert_eq!(after, vec![".", ".."]); } + + #[test] + fn search_on_the_bare_mount_root_finds_nothing() { + // #577 case 3: FindFirstFile("G:\\") must not list the overlay/game host + // folders as entries of the title. + let f = HookFixture::new("rootsearch"); + let got = collect_game_entries(&f.vfs, "", |_| Vec::new()); + assert!(matches!(got, Err(vfs::ERROR_FILE_NOT_FOUND))); + } }