Files in archives obtained from Mac Archive Utility have a zero Size and CompressedSize #206

Closed
opened 2026-01-29 22:08:21 +00:00 by claunia · 1 comment
Owner

Originally created by @KvanTTT on GitHub (Jul 3, 2017).

I'm using the following code to read files from archive:

using (Stream stream = File.OpenRead(sourceArchiveFileName))
{
    using (IReader reader = ReaderFactory.Open(stream))
    {
        while (reader.MoveToNextEntry())
        {
            long size = entry.Size; // Always equals to zero!
            long compressedSize = entry.CompressedSize; // Always equals to zero!
        }
    }
}

I also attach an archive obtained from Mac Archive Utility: file.txt.zip

Originally created by @KvanTTT on GitHub (Jul 3, 2017). I'm using the following code to read files from archive: ```CSharp using (Stream stream = File.OpenRead(sourceArchiveFileName)) { using (IReader reader = ReaderFactory.Open(stream)) { while (reader.MoveToNextEntry()) { long size = entry.Size; // Always equals to zero! long compressedSize = entry.CompressedSize; // Always equals to zero! } } } ``` I also attach an archive obtained from Mac Archive Utility: [file.txt.zip](https://github.com/adamhathcock/sharpcompress/files/1120504/file.txt.zip)
claunia added the question label 2026-01-29 22:08:21 +00:00
Author
Owner

@adamhathcock commented on GitHub (Jul 5, 2017):

If they are archives created with ZipWriter which uses a post-file descriptor to store the file length and compressed size, then a ZipReader won't know the sizes before decompressing.

This is just how the forward-only reading/writing works. It uses the information is has at the time without moving through the streams. I should probably make things nullable to know the difference between no information and an actual zero size.

@adamhathcock commented on GitHub (Jul 5, 2017): If they are archives created with `ZipWriter` which uses a post-file descriptor to store the file length and compressed size, then a `ZipReader` won't know the sizes before decompressing. This is just how the forward-only reading/writing works. It uses the information is has at the time without moving through the streams. I should probably make things nullable to know the difference between no information and an actual zero size.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#206