#path #file #system #file-info #name #directory-info #d-file

file_system

They are very similar to DirectoryInfo and FileInfo of c#

2 releases

0.3.3 Jan 24, 2023
0.3.2 Jan 23, 2023
0.2.4 Jan 19, 2023
0.1.0 Jan 15, 2023

#1266 in Filesystem

36 downloads per month

MIT license

34KB
798 lines

Trait

pub trait DFile {
    fn new<P: AsRef<Path> + Display>(path: P) -> Self;
    fn name(&self) -> &str;
    fn full_name(&self) -> &str;
    fn is_exist(&self) -> bool;
    fn is_read_only(&self) -> bool;
    fn create_self(&self) -> io::Result<()>;
    fn delete_self(&self) -> io::Result<()>;
    fn rename<N: AsRef<Path> + Display>(&mut self, new_name: N) -> io::Result<()>;
    fn move_with_new_name<P: AsRef<Path> + Display>(&mut self, path: P) -> io::Result<()>;
    fn move_to<P: AsRef<Path> + Display>(&mut self, path: P) -> io::Result<()>;
    fn copy_with_new_name<P: AsRef<Path> + Display>(&mut self, path: P) -> io::Result<()>;
    fn copy_to<P: AsRef<Path> + Display>(&mut self, path: P) -> io::Result<()>;
    fn size_bytes(&self) -> io::Result<u64>;
    fn size_kb(&self) -> io::Result<u64>;
    fn size_mb(&self) -> io::Result<u64>;
    fn to_dfile(&self) -> Dfile;
    fn get_parent(&self) -> DirectoryInfo;
    fn get_parent_path(&self) -> String;
    fn add_path<P: AsRef<Path> + Display>(&mut self, path: P);
}

Struct

pub struct DF;
pub struct FileInfo;
pub struct DirectoryInfo;
pub struct Dfile;

Enum

pub enum DFtype;

Usage

use file_system::*;
fn main() {
    let dir = DirectoryInfo::new("directory_path");
    let file = FileInfo::new("file_path");
    let dfile = Dfile::new("dir_or_file_path");
}

No runtime deps