Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
malaterre opened this issue Dec 12, 2023 · 1 comment
Open

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

malaterre opened this issue Dec 12, 2023 · 1 comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO.Compression
Milestone

Comments

@malaterre
Copy link
Contributor

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

@malaterre malaterre added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Dec 12, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 12, 2023
@ghost
Copy link

ghost commented Dec 12, 2023

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: malaterre
Assignees: -
Labels:

api-suggestion, area-System.IO.Compression

Milestone: -

@stephentoub stephentoub added this to the Future milestone Jul 19, 2024
@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO.Compression
Projects
None yet
Development

No branches or pull requests

3 participants