mod os;
pub use os::OsFs;
use std::path::{Path, PathBuf};
use crate::Result;
#[derive(Debug, Clone)]
pub struct FsMetadata {
pub is_file: bool,
pub is_dir: bool,
pub is_symlink: bool,
pub len: u64,
pub mode: u32,
}
#[derive(Debug, Clone)]
pub struct DirEntry {
pub path: PathBuf,
pub name: String,
pub is_dir: bool,
pub is_file: bool,
pub is_symlink: bool,
}
pub trait Fs: Send + Sync {
fn stat(&self, path: &Path) -> Result<FsMetadata>;
fn lstat(&self, path: &Path) -> Result<FsMetadata>;
fn open_read(&self, path: &Path) -> Result<Box<dyn std::io::Read + Send + Sync>>;
fn read_file(&self, path: &Path) -> Result<Vec<u8>>;
fn read_to_string(&self, path: &Path) -> Result<String>;
fn write_file(&self, path: &Path, contents: &[u8]) -> Result<()>;
fn mkdir_all(&self, path: &Path) -> Result<()>;
fn symlink(&self, original: &Path, link: &Path) -> Result<()>;
fn readlink(&self, path: &Path) -> Result<PathBuf>;
fn remove_file(&self, path: &Path) -> Result<()>;
fn remove_dir_all(&self, path: &Path) -> Result<()>;
fn exists(&self, path: &Path) -> bool;
fn is_symlink(&self, path: &Path) -> bool;
fn is_dir(&self, path: &Path) -> bool;
fn read_dir(&self, path: &Path) -> Result<Vec<DirEntry>>;
fn rename(&self, from: &Path, to: &Path) -> Result<()>;
fn copy_file(&self, from: &Path, to: &Path) -> Result<()>;
fn set_permissions(&self, path: &Path, mode: u32) -> Result<()>;
}