#path #file-path #traits #utilities #file-io

path-ext

Provide convenient methods for path operations

2 releases

0.1.1 Aug 14, 2024
0.1.0 Aug 14, 2020

#19 in #trait

Download history 89/week @ 2024-11-21 4/week @ 2024-11-28 15/week @ 2024-12-05 60/week @ 2024-12-12 54/week @ 2024-12-19 25/week @ 2024-12-26 82/week @ 2025-01-02 21/week @ 2025-01-09 29/week @ 2025-01-16 14/week @ 2025-01-23 13/week @ 2025-01-30 86/week @ 2025-02-06 40/week @ 2025-02-13 106/week @ 2025-02-20 494/week @ 2025-02-27 387/week @ 2025-03-06

1,028 downloads per month
Used in y-octo

Custom license

15KB
136 lines

path-ext

Provide convenient methods for path operations

Using

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());
        }
    }
}

output:

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

Dependencies

~0.1–6.5MB
~33K SLoC