Skip to content

Idea: switch to libzip for ZIP archive implementation #19811

@grendello

Description

@grendello

By way of introduction, I work on the Xamarin/Mono team at Microsoft (Xamarin.Android and, from time to time, a foray to the Mono BCL/runtime land) and we've been struggling with various issues related to ZIP archive support over the past few years.

The main problem with all (as far as we can tell) managed implementations is that they implement only a subset of what's supported by the ZIP format and ignore parts that are important on non-Windows systems (especially all flavors of Unix). The biggest issue is lack of support for the extended Unix fields (described in the PKWARE appnote as well as in this document. Support for those fields is important because they make difference between special files and regular files as stored in the archive (that includes file permission bits on Unix). Another issue (less common but still occasionally relevant) is lack of support for symbolic links in managed libraries. Yet another problem is an occasional issue with even opening some ZIP archives (especially created with older versions of ZIP and friends) to the point that we had to resort to using the external unzip program to open some archives.

For the record, the minimum set of extended fields that would need to be implemented is: 0x000d, 0x5855, 0x6375, 0x7855, 0x7875, 0x5455 and symbolic links (which are stored as special files in the ZIP archive)

To address those problems we decided to implement our own support for the ZIP archive and after looking around we chose libzip as the base for our code. The library implements support for ZIP archive format while deferring (de)compression to the venerable zlib library (the same one corefx uses). libzip is cross-platform, works very well on both Unix and Windows systems, is (IMO) very well written and maintained, and uses a permissive license. It does not implement support for interpreting of the extended fields, merely supports writing/reading them as blobs of binary data. For that reason we created a managed wrapper around libzip which not only provides and object-oriented implementation of the libzip APIs but also implements support for the most important extended fields, as listed above. We've been using both libzip and libzipsharp in Xamarin.Android for a while now and found them to work without any issues.

I think it would be great if corefx implemented full, cross-platform, support for ZIP archives and while it could be done in-house I think supporting (by using and contributing to) libzip is would be the best way to go, since many projects would benefit from a single, solid implementation of the ZIP archive format.

Metadata

Metadata

Assignees

No one assigned

    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