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

Add compressed ZIP copying #214

Merged
merged 2 commits into from
Feb 1, 2020
Merged

Add compressed ZIP copying #214

merged 2 commits into from
Feb 1, 2020

Conversation

klauspost
Copy link
Owner

@klauspost klauspost commented Jan 30, 2020

Allow copying content from an existing ZIP file without decompressing+compressing.

New API:

// Copy will copy raw content from input file.
// Optionally a different name can be given to the new file.
func (w *Writer) Copy(name string, src *File) error

// OpenRaw returns a Reader that returns the *compressed* output of the file.
func (f *File) OpenRaw() (io.Reader, error)

// CreateHeaderRaw adds a file to the zip archive using the provided FileHeader
// for the file metadata. Writer takes ownership of fh and may mutate
// its fields. The caller must not modify fh after calling CreateHeaderRaw.
//
// This returns a Writer to which the compressed file contents should be written.
// The file's contents must be written to the io.Writer before the next
// call to Create, Copy, CreateHeader, CreateHeaderRaw or Close.
//
// Using this requires knowledge of populating the FileHeader correctly.
// Generally using the Copy() function is recommended.
func (w *Writer) CreateHeaderRaw(fh *FileHeader) (io.Writer, error)

Allow copying content from an existing ZIP file.
@klauspost klauspost merged commit 26bacdf into master Feb 1, 2020
@klauspost klauspost deleted the compressed-zip-copy branch February 1, 2020 16:50
saracen added a commit to saracen/fastzip that referenced this pull request Jun 7, 2020
klauspost kindly implemented the CreateHeaderRaw proposal
(golang/go#34974) in
klauspost/compress#214. This repository was vendoring
the patched version (https://go-review.googlesource.com/c/go/+/202217/)
but having it supported in a well maintained library already used by fastzip is
a plus.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant