#file #read #write

bin+lib easy_file

easy file system

21 releases

0.1.20 Aug 17, 2022
0.1.19 Aug 14, 2022
0.1.18 Jul 11, 2022
0.1.12 Jun 22, 2022

#504 in Filesystem

Download history 7/week @ 2023-10-14 8/week @ 2023-10-21 54/week @ 2023-10-28 18/week @ 2023-11-04 35/week @ 2023-11-11 7/week @ 2023-11-18 70/week @ 2023-11-25 83/week @ 2023-12-02 15/week @ 2023-12-09 26/week @ 2023-12-16 59/week @ 2023-12-23 23/week @ 2023-12-30 5/week @ 2024-01-06 13/week @ 2024-01-13 34/week @ 2024-01-20 87/week @ 2024-01-27

140 downloads per month
Used in ghc

MIT license

11KB
183 lines

easty file system


use easy_file::*;
fn main() {
    
// create file and write data
match  create_write_file!(std::path::Path::new("./demo.txt"),"demo".as_bytes()){
    Ok(_r)=>{
        println!("done");
    },
    Err(_e)=>{}
}

// read file return Result<Vec<u8>, Box<dyn std::error::Error>>
match  read_file!("./demo.txt"){
    Ok(_r)=>{
        println!("{:?}",_r);
    },
    Err(_e)=>{}
}


// remove file or folder
match  remove!("./test.txt"){
     Ok(_r)=>{
         println!("done");
     },
     Err(_e)=>{}
}

// list directory return Vec<PathBuf>
match  list_dir!("./"){
     Ok(_r)=>{
         println!("{:?}",r);
     },
     Err(_e)=>{}
}

//append data to file
match append_to_file!("./foo.txt", "demo".as_bytes()) {
    Ok(_r) => {
            println!("done");
    }
    Err(_e) => {}
}

//read text file return String
if let Ok(_r) = read_to_string!("./foo.txt") {
        println!("{}", _r);
}

// copy file from a path to another path
if let Ok(_r) = copy_to_path!("./src/foo.txt", "./demo.txt") {}

// move file from a path to another path
if let Ok(_r) = move_to_path!("./src/foo.txt", "./demo.txt") {}

// Creates a new, empty directory at the provided path
if let Ok(_r) = create_dir!("./demo") {}
    
// Recursively create a directory and all of its parent components if they are missing.
if let Ok(_r) = create_dir_all!("./rust/js") {}



}


No runtime deps