fix: is_dir依赖文件存在性,在restore中删除使用

This commit is contained in:
mrbeanc
2023-12-23 18:24:50 +08:00
parent a8977c8e33
commit 028a044ad5
2 changed files with 18 additions and 35 deletions

View File

@@ -147,9 +147,8 @@ pub fn is_inside_dir(file: &Path, dir: &Path) -> bool {
}
}
/// 检测dir是否是file的父目录 (不论文件是否存在)
/// 检测dir是否是file的父目录 (不论文件是否存在) dir可以是一个文件
pub fn is_parent_dir(file: &Path, dir: &Path) -> bool {
assert!(dir.is_dir());
let file = get_absolute_path(file);
let dir = get_absolute_path(dir);
file.starts_with(dir)
@@ -170,15 +169,6 @@ pub fn format_time(time: &std::time::SystemTime) -> String {
datetime.format("%Y-%m-%d %H:%M:%S.%3f").to_string()
}
/// 过滤出路径数组中的目录
pub fn filter_dirs(paths: &Vec<PathBuf>) -> HashSet<PathBuf> {
paths.iter().filter(|path| path.is_dir()).cloned().collect()
}
pub fn filter_files(paths: &Vec<PathBuf>) -> HashSet<PathBuf> {
paths.iter().filter(|path| path.is_file()).cloned().collect()
}
/// 将路径中的分隔符统一为当前系统的分隔符
fn unify_path_separator(path: &Path) -> PathBuf {
#[cfg(windows)]