From d961c6b03fac0897067028c5507011e7e85cff30 Mon Sep 17 00:00:00 2001 From: Eashwar Ranganathan Date: Fri, 21 Nov 2025 10:41:27 -0500 Subject: [PATCH] Initialize headers by default to EntryType::Regular --- src/entry_type.rs | 8 ++++++-- src/header.rs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/entry_type.rs b/src/entry_type.rs index f7773552..6f81591a 100644 --- a/src/entry_type.rs +++ b/src/entry_type.rs @@ -5,6 +5,8 @@ /// distinguish between types of content. #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum EntryType { + /// Legacy Regular file + LegacyRegular, /// Regular file Regular, /// Hard link @@ -47,7 +49,8 @@ impl EntryType { /// appropriate to create a file type from. pub fn new(byte: u8) -> EntryType { match byte { - b'\x00' | b'0' => EntryType::Regular, + b'\x00' => EntryType::LegacyRegular, + b'0' => EntryType::Regular, b'1' => EntryType::Link, b'2' => EntryType::Symlink, b'3' => EntryType::Char, @@ -67,6 +70,7 @@ impl EntryType { /// Returns the raw underlying byte that this entry type represents. pub fn as_byte(&self) -> u8 { match *self { + EntryType::LegacyRegular => b'\x00', EntryType::Regular => b'0', EntryType::Link => b'1', EntryType::Symlink => b'2', @@ -126,7 +130,7 @@ impl EntryType { /// Returns whether this type represents a regular file. pub fn is_file(&self) -> bool { - self == &EntryType::Regular + matches!(self, &EntryType::Regular | &EntryType::LegacyRegular) } /// Returns whether this type represents a hard link. diff --git a/src/header.rs b/src/header.rs index fd4a1deb..da308d6e 100644 --- a/src/header.rs +++ b/src/header.rs @@ -160,6 +160,7 @@ impl Header { gnu.magic = *b"ustar "; gnu.version = *b" \0"; } + header.set_entry_type(EntryType::Regular); header.set_mtime(0); header } @@ -180,6 +181,7 @@ impl Header { gnu.magic = *b"ustar\0"; gnu.version = *b"00"; } + header.set_entry_type(EntryType::Regular); header.set_mtime(0); header }