diff --git a/src/instance.rs b/src/instance.rs index ad08a5d..b6a80b6 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -82,10 +82,8 @@ pub fn files_to_install_mod( let files = match determain_mod_kind(mod_to_install, &mod_location)? { ModKind::Fomod(xml_path) => install_fomod(instance, xml_path, &mod_location)?, - ModKind::EmbeddedData(data_path) => { - install_from_dir(mod_to_install, mod_location.join(data_path))? - } - ModKind::Root => install_from_dir(mod_to_install, mod_location)?, + ModKind::EmbeddedData(_data_path) => install_from_dir(mod_to_install, mod_location)?, + ModKind::Root => install_root(mod_to_install, mod_location)?, ModKind::Unkown => install_from_dir_to_data(mod_to_install, mod_location)?, }; @@ -149,6 +147,22 @@ fn install_from_dir( ) -> anyhow::Result> { let glob_filter = create_glob_filter(mod_config.ignore())?; + let files: Vec<_> = walk_all_files(&mod_location)? + .map(|entry| entry.path().strip_prefix(&mod_location).unwrap().to_owned()) + .filter(|rel_path| !glob_filter.is_match(rel_path)) + .filter(|rel_path| should_be_included(rel_path)) + .map(|rel_path| ModFile::new(&rel_path, &rel_path, 0)) + .collect(); + + Ok(files) +} + +fn install_root( + mod_config: &ModConfig, + mod_location: impl AsRef, +) -> anyhow::Result> { + let glob_filter = create_glob_filter(mod_config.ignore())?; + let files: Vec<_> = walk_all_files(&mod_location)? .map(|entry| entry.path().strip_prefix(&mod_location).unwrap().to_owned()) .filter(|rel_path| !glob_filter.is_match(rel_path))