2 个版本
0.3.3 | 2023 年 1 月 24 日 |
---|---|
0.3.2 | 2023 年 1 月 23 日 |
0.2.4 |
|
0.1.0 |
|
#1093 in 文件系统
34KB
798 行
特质
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);
}
结构体
pub struct DF;
pub struct FileInfo;
pub struct DirectoryInfo;
pub struct Dfile;
枚举
pub enum DFtype;
用法
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");
}