mirror of
https://github.com/vladtrc/iw4L
synced 2026-10-25 18:05:19 -04:00
Boot: zone discovery skips cargo output and the artifacts folder
When the games root is the build's own `target/play`, discovery walked every file of cargo's output (incremental, deps, build, .fingerprint, examples) and the artifacts folder, several times at boot: the window sat white and "Not Responding" for seconds before the map loaded. Those folders never hold zones, so the walk skips them (retail MW2, MW3 and Black Ops installs have no folders by these names). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -250,6 +250,28 @@ fn game_files(root: &Path) -> impl Iterator<Item = Result<PathBuf, String>> {
|
||||
files_under(search_roots(root))
|
||||
}
|
||||
|
||||
/// Folders the game never keeps zones in: cargo's output when the games root is the build's own
|
||||
/// `target/play` (tens of thousands of files, walked on every discovery), and our own
|
||||
/// artifacts.
|
||||
const NOT_GAME_DIRS: [&str; 6] = [
|
||||
"incremental",
|
||||
"deps",
|
||||
"build",
|
||||
".fingerprint",
|
||||
"examples",
|
||||
"iw4l-artifacts",
|
||||
];
|
||||
|
||||
fn is_not_game_dir(path: &Path) -> bool {
|
||||
path.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.is_some_and(|name| {
|
||||
NOT_GAME_DIRS
|
||||
.iter()
|
||||
.any(|skip| name.eq_ignore_ascii_case(skip))
|
||||
})
|
||||
}
|
||||
|
||||
fn files_under(roots: Vec<PathBuf>) -> impl Iterator<Item = Result<PathBuf, String>> {
|
||||
let mut pending: VecDeque<_> = roots.into_iter().map(Ok).collect();
|
||||
let mut visited = HashSet::new();
|
||||
@@ -259,6 +281,9 @@ fn files_under(roots: Vec<PathBuf>) -> impl Iterator<Item = Result<PathBuf, Stri
|
||||
Ok(path) => path,
|
||||
Err(error) => return Some(Err(error)),
|
||||
};
|
||||
if is_not_game_dir(&path) {
|
||||
continue;
|
||||
}
|
||||
let canonical = match std::fs::canonicalize(&path) {
|
||||
Ok(path) => path,
|
||||
Err(error) => {
|
||||
|
||||
Reference in New Issue
Block a user