use crate::fs::Metadata;
use anyhow::Context;
use std::fs::FileType;
use std::ops::Deref;
#[derive(Debug, derive_more::From, derive_more::Into)]
pub struct DirEntry {
de: std::fs::DirEntry,
}
impl DirEntry {
pub fn metadata(&self) -> anyhow::Result<Metadata> {
self.de
.metadata()
.map(|md| Metadata::from((md, self.path())))
.with_context(|| format!("while processing path {:?}", self.path().display()))
}
pub fn file_type(&self) -> anyhow::Result<FileType> {
self.de
.file_type()
.with_context(|| format!("while processing path {:?}", self.path().display()))
}
}
impl Deref for DirEntry {
type Target = std::fs::DirEntry;
fn deref(&self) -> &Self::Target {
&self.de
}
}