Skip to content

System.IO.Compression should store NoCompression entries without wrapping them in Deflate streams #26185

@Marv51

Description

@Marv51

Currently when a ZipArchive is created and an entry is added with the CompressionLevel set to "no-compression" the file inside the archive is still wrapped in a deflate stream. The deflate stream correctly does not to compress the file.

However, zip does natively support uncompressed files. The compression method "stored" is made for this.

To create OpenDocument format files (ods, odt etc.) it is required to store the mimetype file without wrapping it in any compression stream. They do this, so that the mimetype can always found at a specific offset.
This change should also be a tiny performance and archive size improvement.

I have attached a diff of the changes necessary to implement this. I've run the tests, however I've not yet been able to build corefx in a way that I can use with my app to validate the patch is working.
diff.zip

If this is something you think is possible to merge, I can spend more time on this to create a proper PR.

Metadata

Metadata

Assignees

Labels

area-System.IO.CompressionenhancementProduct code improvement that does NOT require public API changes/additions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions