the great refactor
This commit is contained in:
16
src/utils.rs
16
src/utils.rs
@@ -4,6 +4,8 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub fn path_to_lowercase(path: impl AsRef<Path>) -> PathBuf {
|
||||
PathBuf::from(path.as_ref().to_string_lossy().to_lowercase())
|
||||
}
|
||||
@@ -40,3 +42,17 @@ pub fn resolve_case_insensitive(
|
||||
|
||||
Ok(Some(current))
|
||||
}
|
||||
|
||||
/// Use walkdir to walk all actual files in a dir
|
||||
/// Returns early id any error occurs
|
||||
pub fn walk_all_files(
|
||||
path: impl AsRef<Path>,
|
||||
) -> Result<impl Iterator<Item = walkdir::DirEntry>, walkdir::Error> {
|
||||
let a = WalkDir::new(path)
|
||||
.into_iter()
|
||||
.collect::<Result<Vec<_>, walkdir::Error>>()?
|
||||
.into_iter()
|
||||
.filter(|entry| entry.file_type().is_file());
|
||||
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user