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-> Result<(), Self::Error>;
fn rename(&self, former: &str, new: &str) -> Result<(), Self::Error>;
fn set_permissions(&self, name: &str, permissions: u16) -> Result<(), Self::Error>;
type Writer: std::io::Write;
fn write_file(&self, file: &str) -> Result<Self::Writer, Self::Error>;
pub trait WorkingCopy: WorkingCopyRead {
fn create_dir_all(&self, path: &str) -> Result<(), Self::Error>;
fn remove_path(&self, name: &str, rec: bool) -> Result<(), Self::Error>;
fn rename(&self, former: &str, new: &str) -> Result<(), Self::Error>;
fn set_permissions(&self, name: &str, permissions: u16) -> Result<(), Self::Error>;
type Writer: std::io::Write;
fn write_file(&self, file: &str) -> Result<Self::Writer, Self::Error>;
}
fn create_dir_all(&self, file: &str) -> Result<(), Self::Error> {
let not_already_exists = {
let m = self.0.lock();
m.get_file(file).is_none()
};
if not_already_exists {
let last = SystemTime::now();
self.add_inode(
file,
Inode::Directory {
meta: InodeMetadata::new(0o100, true),
children: FileTree {
children: HashMap::default(),
},
last_modified: last,
},
);
}
Ok(())
}
impl WorkingCopy for Memory {
fn create_dir_all(&self, file: &str) -> Result<(), Self::Error> {
let not_already_exists = {
let m = self.0.lock();
m.get_file(file).is_none()
};
if not_already_exists {
let last = SystemTime::now();
self.add_inode(
file,
Inode::Directory {
meta: InodeMetadata::new(0o100, true),
children: FileTree {
children: HashMap::default(),
},
last_modified: last,
},
);
}
Ok(())
}
fn create_dir_all(&self, file: &str) -> Result<(), Self::Error> {
debug!("create_dir_all {:?}", file);
Ok(std::fs::create_dir_all(&self.path(file))?)
}