22 lines
679 B
Rust
22 lines
679 B
Rust
//
|
|
use crate::fs::{DirItem, DirItemIterator, Result};
|
|
|
|
use super::path::{DirG, PathReal};
|
|
|
|
impl<'base, 'path> PathReal<'base, 'path, DirG> {
|
|
pub fn create(&mut self) -> Result<()> {
|
|
self.check_error()?;
|
|
std::fs::create_dir(self.as_pathbuf()).map_err(Into::into)
|
|
}
|
|
|
|
pub fn create_all(&mut self) -> Result<()> {
|
|
self.check_error()?;
|
|
std::fs::create_dir_all(self.as_pathbuf()).map_err(Into::into)
|
|
}
|
|
|
|
pub fn read(&mut self) -> Result<Box<dyn Iterator<Item = Result<DirItem>>>> {
|
|
self.check_error()?;
|
|
let read_dir = std::fs::read_dir(self.as_pathbuf())?;
|
|
Ok(Box::new(DirItemIterator::new(read_dir)))
|
|
}
|
|
}
|