implemented unkown mod install
This commit is contained in:
@@ -79,7 +79,7 @@ pub fn files_to_install_mod(
|
||||
install_from_dir(mod_to_install, mod_location.join(data_path))?
|
||||
}
|
||||
ModKind::Root => install_from_dir(mod_to_install, mod_location)?,
|
||||
ModKind::Unkown => todo!(),
|
||||
ModKind::Unkown => install_from_dir_to_data(mod_to_install, mod_location)?,
|
||||
};
|
||||
|
||||
Ok(files)
|
||||
@@ -138,6 +138,22 @@ fn install_from_dir(
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
fn install_from_dir_to_data(
|
||||
mod_config: &ModConfig,
|
||||
path: impl AsRef<Path>,
|
||||
) -> anyhow::Result<Vec<ModFile>> {
|
||||
let glob_filter = create_glob_filter(mod_config.ignore())?;
|
||||
let data = PathBuf::from("Data");
|
||||
let files: Vec<_> = walk_files_recursive(&path)?
|
||||
.map(|entry| entry.path())
|
||||
.map(|file_path| file_path.strip_prefix(&path).unwrap().to_owned())
|
||||
.filter(|rel_path| should_be_included(rel_path))
|
||||
.filter(|rel_path| !glob_filter.is_match(rel_path))
|
||||
.map(|rel_path| ModFile::new(&rel_path, data.join(&rel_path), 0))
|
||||
.collect();
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
fn create_glob_filter(rules: &[String]) -> anyhow::Result<GlobSet> {
|
||||
let mut builder = GlobSetBuilder::new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user