forked from Cutieguwu/raven
Initial Commit.
This commit is contained in:
16
src/fs.rs
Normal file
16
src/fs.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn expand_files<P: AsRef<Path>>(path: P) -> anyhow::Result<Vec<PathBuf>> {
|
||||
let path = path.as_ref();
|
||||
|
||||
if path.is_file() {
|
||||
return Ok(vec![path.to_path_buf()]);
|
||||
}
|
||||
|
||||
Ok(std::fs::read_dir(path)?
|
||||
.filter_map(|entry| {
|
||||
let path = entry.ok()?.path();
|
||||
if path.is_file() { Some(path) } else { None }
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
Reference in New Issue
Block a user