Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder
- Title data: `%LOCALAPPDATA%\XCL\<title>\` (`%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

Expand Down
32 changes: 31 additions & 1 deletion crates/xcl/src/vfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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]
Expand Down
Loading