Skip to content

[API Proposal]: Make ZipArchiveEntry.CompressionMethod public #95909

Open
@malaterre

Description

@malaterre

Background and motivation

We are using Zip as simple container for a bunch of image files (JPEG). We need to make sure that function only process STORE ZipArchiveEntry (aka NoCompression). Right now we compare entry.CompressedLength against entry.Length to deduce if the entry is really STORE (and not DEFLATE).

It would make sense to expose directly CompressionMethod as read-only for simplicity.

API Proposal

class ZipArchiveEntry
{
  public CompressionMethodValues CompressionMethod
        {
            get { return _storedCompressionMethod; }
        }
}

API Usage

        using var archive = ZipFile.Open(zipFileName, ZipArchiveMode.Read);
        foreach (var entry in archive.Entries)
        {
            if (entry.CompressionMethod != CompressionMethodValues.Stored )
              throw new NotImplementedException("Only process STORE type")
        }

Alternative Designs

        using var archive = ZipFile.Open(zipFileName, ZipArchiveMode.Read);
        foreach (var entry in archive.Entries)
        {
            if (entry.CompressedLength != entry.Length)
              throw new NotImplementedException("Only process STORE type")
        }

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions