Error if pack input is not a directory

This commit is contained in:
Truman Kilen 2023-01-31 23:14:39 -06:00
parent b1cfe4aa1f
commit a5a587f94a

View file

@ -179,7 +179,6 @@ fn pack(args: ActionPack) -> Result<(), unpak::Error> {
.unwrap_or_else(|| Path::new(&args.input).with_extension("pak"));
fn collect_files(paths: &mut Vec<PathBuf>, dir: &Path) -> io::Result<()> {
if dir.is_dir() {
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
@ -189,10 +188,12 @@ fn pack(args: ActionPack) -> Result<(), unpak::Error> {
paths.push(entry.path());
}
}
}
Ok(())
}
let input_path = Path::new(&args.input);
if !input_path.is_dir() {
return Err(unpak::Error::Other("input is not a directory"));
}
let mut paths = vec![];
collect_files(&mut paths, input_path)?;
paths.sort();