mirror of
https://github.com/Drop-OSS/droplet.git
synced 2025-11-10 20:42:14 +10:00
initial commit
This commit is contained in:
21
src/file_utils.rs
Normal file
21
src/file_utils.rs
Normal file
@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user