#path #utilities #traits

path-ext

提供便捷的路径操作方法

2 个版本

新版本 0.1.1 2024年8月14日
0.1.0 2020年8月14日

392文件系统 中排名

Download history 2/week @ 2024-05-13 10/week @ 2024-05-20 10/week @ 2024-05-27 5/week @ 2024-06-03 3/week @ 2024-06-10 8/week @ 2024-06-17 4/week @ 2024-06-24 56/week @ 2024-07-08 16/week @ 2024-07-22 2/week @ 2024-07-29 3/week @ 2024-08-05 119/week @ 2024-08-12

每月 140 次下载
用于 y-octo

自定义许可协议

15KB
136

path-ext

提供便捷的路径操作方法

使用

fn test_path() {
    let path1 = PathBuf::from("Z:\\Movies\\[VCB-Studio] Fate Zero [Ma10p_1080p]\\[VCB-Studio] Fate Zero [04][Ma10p_1080p][x265_flac].mkv");
    println!("full path: {}", path1.full_str());
    println!("file ext: {}", path1.ext_str());
    println!("file stem: {}", path1.stem_str());
    println!("file name: {}", path1.name_str());
    let path2 = PathBuf::from("Z:\\Movies");
    let path3 = PathBuf::from("[VCB-Studio] Fate Zero [Ma10p_1080p]\\[VCB-Studio] Fate Zero [04][Ma10p_1080p][x265_flac].mkv");
    let path4 = path2.merge(path3);
    println!("merged full path: {}", path4.full_str());
    println!("file: {}", path1.is_file());
    println!("dir: {}", path2.is_dir());
    if let Some(parent) = path4.parent() {
        for path in parent.walk_dir(|p| p.is_dir()) {
            println!("subdir: {}", path.full_str());
        }
    }
}

输出

running 1 test
full path: Z:\Movies\[VCB-Studio] Fate Zero [Ma10p_1080p]\[VCB-Studio] Fate Zero [04][Ma10p_1080p][x265_flac].mkv
file ext: mkv
file stem: [VCB-Studio] Fate Zero [04][Ma10p_1080p][x265_flac]
file name: [VCB-Studio] Fate Zero [04][Ma10p_1080p][x265_flac].mkv
merged full path: Z:\Movies\[VCB-Studio] Fate Zero [Ma10p_1080p]\[VCB-Studio] Fate Zero [04][Ma10p_1080p][x265_flac].mkv
file: true
dir: true
subdir: Z:\Movies\[VCB-Studio] Fate Zero [Ma10p_1080p]
subdir: Z:\Movies\[VCB-Studio] Fate Zero [Ma10p_1080p]\CDs
subdir: Z:\Movies\[VCB-Studio] Fate Zero [Ma10p_1080p]\Scans
subdir: Z:\Movies\[VCB-Studio] Fate Zero [Ma10p_1080p]\SPs
test test_path ... ok

依赖

~0.1–7MB
~40K SLoC