use std::{
ffi::OsStr,
fs,
path::{Path, PathBuf},
};
#[derive(Debug, Clone)]
pub struct DirEntry {
pub(super) path: PathBuf,
pub(super) file_type: fs::FileType,
pub(super) follow_link: bool,
pub(super) depth: usize,
#[cfg(unix)]
pub(super) ino: u64,
#[cfg(unix)]
pub(super) metadata: once_cell::sync::OnceCell<fs::Metadata>,
#[cfg(windows)]
pub(super) metadata: fs::Metadata,
}
impl DirEntry {
pub fn path(&self) -> &Path {
&self.path
}
pub fn into_path(self) -> PathBuf {
self.path
}
pub fn file_type(&self) -> fs::FileType {
self.file_type
}
pub fn is_dir(&self) -> bool {
self.file_type.is_dir()
}
pub fn depth(&self) -> usize {
self.depth
}
pub fn file_name(&self) -> &OsStr {
self.path
.file_name()
.unwrap_or_else(|| self.path.as_os_str())
}
}