ziputil

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ziputil writes zip entries without recompressing them, for generators that stream an archive built from another one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyData

func CopyData(ctx context.Context, w io.Writer, f *zip.File) error

CopyData copies f's raw data to w, checking ctx between chunks. A source that ends before the data does is an error rather than a short entry.

func CopyRaw

func CopyRaw(ctx context.Context, zw *zip.Writer, f *zip.File) error

CopyRaw writes f to zw as is, without decompressing it.

func CopyRawWith

func CopyRawWith(zw *zip.Writer, f *zip.File, body func(io.Writer, *zip.File) error) error

CopyRawWith creates f's entry in zw with RawHeader and has body write its raw data, unless it is a directory. Measuring an archive passes a body that writes placeholder bytes, so the measured size comes from the same code as the real write.

func RawHeader

func RawHeader(f *zip.File) *zip.FileHeader

RawHeader returns a header for copying f with zip.Writer.CreateRaw. The sizes and CRC go in the local header, so no data descriptor follows the data, and the source's ZIP64 extra field is dropped: it describes the source's offsets, and the writer adds its own when the output needs one. A directory becomes an empty stored entry, since the writer takes no data for one; some tools deflate a directory's empty body.

Types

type Entry

type Entry struct {
	Header zip.FileHeader
	Data   []byte
}

Entry is an entry compressed ahead of writing, so its size is known and writing it is a plain copy.

func Compress

func Compress(name string, method uint16, content []byte) (*Entry, error)

Compress compresses content with method, which is zip.Store or zip.Deflate.

func (*Entry) Write

func (e *Entry) Write(zw *zip.Writer) error

Write writes e to zw.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL