Skip to content
Merged
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
2 changes: 0 additions & 2 deletions src/SharpCompress/Common/Zip/Headers/DirectoryEntryHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ internal override void Read(BinaryReader reader)

public long RelativeOffsetOfEntryHeader { get; set; }

public uint ExternalFileAttributes { get; set; }

public ushort InternalFileAttributes { get; set; }

public ushort DiskNumberStart { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,7 @@ protected void LoadExtra(byte[] extra)

internal bool IsZip64 => CompressedSize >= uint.MaxValue;

internal uint ExternalFileAttributes { get; set; }

internal string? Comment { get; set; }
}
1 change: 1 addition & 0 deletions src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ DirectoryEntryHeader directoryEntryHeader

// populate fields only known from the DirectoryEntryHeader
localEntryHeader.HasData = directoryEntryHeader.HasData;
localEntryHeader.ExternalFileAttributes = directoryEntryHeader.ExternalFileAttributes;
localEntryHeader.Comment = directoryEntryHeader.Comment;

if (FlagUtility.HasFlag(localEntryHeader.Flags, HeaderFlags.UsePostDataDescriptor))
Expand Down
2 changes: 2 additions & 0 deletions src/SharpCompress/Common/Zip/ZipEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ internal ZipEntry(ZipFilePart? filePart)

internal override IEnumerable<FilePart> Parts => _filePart.Empty();

public override int? Attrib => (int?)_filePart?.Header.ExternalFileAttributes;

public string? Comment => _filePart?.Header.Comment;
}
11 changes: 11 additions & 0 deletions tests/SharpCompress.Test/Zip/ZipArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -832,4 +832,15 @@ public void Zip_EntryCommentAfterEntryRead()
using var _ = firstEntry.OpenEntryStream();
Assert.Equal(29, firstEntry.Comment.Length);
}

[Fact]
public void Zip_FilePermissions()
{
using var archive = ArchiveFactory.Open(Path.Combine(TEST_ARCHIVES_PATH, "Zip.644.zip"));

var firstEntry = archive.Entries.First();
const int S_IFREG = 0x8000;
const int expected = (S_IFREG | 0b110_100_100) << 16; // 0644 mode regular file
Assert.Equal(expected, firstEntry.Attrib);
}
}
Binary file added tests/TestArchives/Archives/Zip.644.zip
Binary file not shown.