diff --git a/README.md b/README.md
index 0710608d4d..97a525deb4 100644
--- a/README.md
+++ b/README.md
@@ -137,6 +137,8 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder
- Title data: `%LOCALAPPDATA%\XCL\
\` (`%XCL_DATA_ROOT%`): `xcl.toml`, `overlay\`, `saves\`,
`pls\` (the title's `S:\`), `temp\` (`T:\`), `cache\`, `logs\xcl.log`, `logs\report.json` (the
previous run's: `xcl.prev.log`, `report.prev.json`).
+- Mount prefixes accept either slash style, including directory mounts such as `GAME:/data`;
+ matching still respects directory boundaries.
## Tests
diff --git a/crates/xcl/src/vfs.rs b/crates/xcl/src/vfs.rs
index dd02bcb67a..a5cb9db2e8 100644
--- a/crates/xcl/src/vfs.rs
+++ b/crates/xcl/src/vfs.rs
@@ -165,7 +165,14 @@ impl Vfs {
.unwrap_or_default();
let mut mounts: Vec<(String, String)> = mounts
.into_iter()
- .map(|(p, t)| (p.to_ascii_lowercase().trim_end_matches(['\\', '/']).to_string(), trim_sep(&norm(&t))))
+ .map(|(mut p, t)| {
+ if p.contains('/') {
+ p = norm(&p);
+ }
+ p.make_ascii_lowercase();
+ p.truncate(p.trim_end_matches('\\').len());
+ (p, trim_sep(&norm(&t)))
+ })
.collect();
// longest prefix first ("GAME:" before "G:")
mounts.sort_by(|a, b| b.0.len().cmp(&a.0.len()));
@@ -761,6 +768,29 @@ mod tests {
assert_eq!(v.classify("C:\\Windows\\notepad.exe"), Target::Pass);
}
+ #[test]
+ fn mount_prefixes_accept_either_separator() {
+ let f = Fixture::new("prefix_slashes");
+ let game = f.game();
+ let target = f.dir.join("redirect").to_string_lossy().into_owned();
+ for prefix in ["GAME:\\data", "GAME:/data", "GaMe:\\data/", "game:/data/"] {
+ let v = Vfs::new(
+ &game,
+ &f.dir.join("xcldata"),
+ vec![("GAME:".into(), game.to_string_lossy().into_owned()), (prefix.into(), target.clone())],
+ );
+ for path in ["GAME:\\data\\hello.txt", "game:/data/hello.txt"] {
+ assert_eq!(v.classify(path), Target::Translated(format!("{target}\\hello.txt")), "{prefix}");
+ }
+ assert_eq!(v.classify("GAME:\\data"), Target::Translated(target.clone()), "{prefix}");
+ assert_eq!(
+ v.classify("GAME:\\database\\hello.txt"),
+ Target::Game { rel: "database\\hello.txt".into() },
+ "{prefix}"
+ );
+ }
+ }
+
/// The console's "D:" mount on a PC whose game and XCL data are on its D: drive: paths
/// already inside those folders are the PC's, everything else on the drive is the console's.
#[test]