diff --git a/src/backup/catalog.rs b/src/backup/catalog.rs index 9ccff29f..bc2e471e 100644 --- a/src/backup/catalog.rs +++ b/src/backup/catalog.rs @@ -15,7 +15,7 @@ use crate::pxar::catalog::BackupCatalogWriter; #[repr(u8)] #[derive(Copy,Clone,PartialEq)] -enum CatalogEntryType { +pub(crate) enum CatalogEntryType { Directory = b'd', File = b'f', Symlink = b'l', @@ -44,6 +44,21 @@ impl TryFrom for CatalogEntryType { } } +impl From<&DirEntryAttribute> for CatalogEntryType { + fn from(value: &DirEntryAttribute) -> Self { + match value { + DirEntryAttribute::Directory { .. } => CatalogEntryType::Directory, + DirEntryAttribute::File { .. } => CatalogEntryType::File, + DirEntryAttribute::Symlink => CatalogEntryType::Symlink, + DirEntryAttribute::Hardlink => CatalogEntryType::Hardlink, + DirEntryAttribute::BlockDevice => CatalogEntryType::BlockDevice, + DirEntryAttribute::CharDevice => CatalogEntryType::CharDevice, + DirEntryAttribute::Fifo => CatalogEntryType::Fifo, + DirEntryAttribute::Socket => CatalogEntryType::Socket, + } + } +} + impl fmt::Display for CatalogEntryType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", char::from(*self as u8))