mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-02-08 04:43:36 +08:00
fix: is_dir依赖文件存在性,在restore中删除使用
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user