mirror of
https://github.com/Drop-OSS/droplet.git
synced 2025-11-09 20:12:18 +10:00
22 lines
562 B
Rust
22 lines
562 B
Rust
use std::{fs::{self, metadata}, path::{Path, PathBuf}};
|
|
|
|
pub fn _list_files(vec: &mut Vec<PathBuf>, path: &Path) {
|
|
if metadata(&path).unwrap().is_dir() {
|
|
let paths = fs::read_dir(&path).unwrap();
|
|
for path_result in paths {
|
|
let full_path = path_result.unwrap().path();
|
|
if metadata(&full_path).unwrap().is_dir() {
|
|
_list_files(vec, &full_path);
|
|
} else {
|
|
vec.push(full_path);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn list_files(path: &Path) -> Vec<PathBuf> {
|
|
let mut vec = Vec::new();
|
|
_list_files(&mut vec, &path);
|
|
return vec;
|
|
}
|