Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down