ziplib

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package ziplib provides core zip/unzip functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unzip

func Unzip(zipPath string, opts UnzipOptions) error

Unzip extracts the contents of a zip archive.

func Zip

func Zip(zipPath string, files []string, opts ZipOptions) error

Zip creates a zip archive at zipPath containing the given files. Directories are included recursively only if opts.Recursive is true; otherwise a warning is printed and the directory is skipped.

Types

type ListEntry

type ListEntry struct {
	Name             string
	UncompressedSize uint64
	CompressedSize   uint64
	Modified         time.Time
	IsDir            bool
}

ListEntry holds metadata about a single entry in a zip archive.

func List

func List(zipPath string) ([]ListEntry, error)

List returns metadata for all entries in a zip archive.

type UnzipOptions

type UnzipOptions struct {
	// OutputDir is the directory to extract files into. Defaults to ".".
	OutputDir string
	// Overwrite allows overwriting existing files.
	Overwrite bool
	// JunkPaths strips directory components from file names on extraction.
	JunkPaths bool
	// FilePatterns filters which files to extract. Empty means extract all.
	FilePatterns []string
	// Output is where status messages are written. If nil, messages are discarded.
	Output io.Writer
}

UnzipOptions configures the behavior of the Unzip function.

type ZipOptions

type ZipOptions struct {
	// Recursive enables recursive directory traversal.
	Recursive bool
	// CompressionLevel sets the flate compression level (0-9).
	// -1 means default compression.
	CompressionLevel int
	// ExcludePatterns is a list of glob patterns to exclude from the archive.
	ExcludePatterns []string
	// Output is where status messages are written. If nil, messages are discarded.
	Output io.Writer
}

ZipOptions configures the behavior of the Zip function.

Jump to

Keyboard shortcuts

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