21 lines
No EOL
525 B
Rust
21 lines
No EOL
525 B
Rust
use std::path::PathBuf;
|
|
|
|
pub fn get_files<S: Into<String>>(path: S) -> Vec<PathBuf> {
|
|
let mut files = Vec::new();
|
|
let mut dirs = Vec::new();
|
|
dirs.push(PathBuf::from(path.into()));
|
|
|
|
while let Some(dir) = dirs.pop() {
|
|
for entry in std::fs::read_dir(dir).unwrap() {
|
|
let entry = entry.unwrap();
|
|
let path = entry.path();
|
|
if path.is_dir() {
|
|
dirs.push(path);
|
|
} else {
|
|
files.push(path);
|
|
}
|
|
}
|
|
}
|
|
|
|
files
|
|
} |