kxio/src/fs/dir.rs
Paul Campbell d2ee798f25
All checks were successful
Rust / build (map[name:nightly]) (push) Successful in 1m59s
Rust / build (map[name:stable]) (push) Successful in 3m25s
Release Please / Release-plz (push) Successful in 34s
refactor: use generics for path type
2024-11-02 12:16:42 +00:00

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)))
}
}