mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 19:04:07 +00:00
Error if pack input is not a directory
This commit is contained in:
parent
b1cfe4aa1f
commit
a5a587f94a
1 changed files with 10 additions and 9 deletions
|
@ -179,20 +179,21 @@ fn pack(args: ActionPack) -> Result<(), unpak::Error> {
|
||||||
.unwrap_or_else(|| Path::new(&args.input).with_extension("pak"));
|
.unwrap_or_else(|| Path::new(&args.input).with_extension("pak"));
|
||||||
|
|
||||||
fn collect_files(paths: &mut Vec<PathBuf>, dir: &Path) -> io::Result<()> {
|
fn collect_files(paths: &mut Vec<PathBuf>, dir: &Path) -> io::Result<()> {
|
||||||
if dir.is_dir() {
|
for entry in fs::read_dir(dir)? {
|
||||||
for entry in fs::read_dir(dir)? {
|
let entry = entry?;
|
||||||
let entry = entry?;
|
let path = entry.path();
|
||||||
let path = entry.path();
|
if path.is_dir() {
|
||||||
if path.is_dir() {
|
collect_files(paths, &path)?;
|
||||||
collect_files(paths, &path)?;
|
} else {
|
||||||
} else {
|
paths.push(entry.path());
|
||||||
paths.push(entry.path());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
let input_path = Path::new(&args.input);
|
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![];
|
let mut paths = vec![];
|
||||||
collect_files(&mut paths, input_path)?;
|
collect_files(&mut paths, input_path)?;
|
||||||
paths.sort();
|
paths.sort();
|
||||||
|
|
Loading…
Reference in a new issue