#[derive(Debug, Clone)]
pub struct DirEntry {
path: PathBuf,
is_file: bool,
is_dir: bool,
modified: Option<std::time::SystemTime>,
}
impl DirEntry {
#[must_use]
pub const fn new(path: PathBuf, is_file: bool, is_dir: bool) -> Self {
Self {
path,
is_file,
is_dir,
modified: None,
}
}
#[must_use]
pub const fn with_modified(
path: PathBuf,
is_file: bool,
is_dir: bool,
modified: std::time::SystemTime,
) -> Self {
Self {
path,
is_file,
is_dir,
modified: Some(modified),
}
}
#[must_use]
pub fn path(&self) -> &Path {
&self.path
}
#[must_use]
pub const fn is_file(&self) -> bool {
self.is_file
}
#[must_use]
pub const fn is_dir(&self) -> bool {
self.is_dir
}
#[must_use]
pub fn file_name(&self) -> Option<&std::ffi::OsStr> {
self.path.file_name()
}
#[must_use]
pub const fn modified(&self) -> Option<std::time::SystemTime> {
self.modified
}
}