fastzip: github.com/saracen/fastzip Index | Files | Directories

package fastzip

import "github.com/saracen/fastzip"

Index

Package Files

archiver.go archiver_options.go archiver_unix.go extractor.go extractor_options.go extractor_unix.go register.go util.go

Variables

var ErrMinConcurrency = errors.New("concurrency must be at least 1")

func FlateCompressor Uses

func FlateCompressor(level int) func(w io.Writer) (io.WriteCloser, error)

FlateCompressor returns a pooled performant zip.Compressor configured to a specified compression level. Invalid flate levels will panic.

func FlateDecompressor Uses

func FlateDecompressor() func(r io.Reader) io.ReadCloser

FlateDecompressor returns a pooled performant zip.Decompressor.

func StdFlateCompressor Uses

func StdFlateCompressor(level int) func(w io.Writer) (io.WriteCloser, error)

StdFlateCompressor returns a pooled standard library zip.Compressor configured to a specified compression level. Invalid flate levels will panic.

func StdFlateDecompressor Uses

func StdFlateDecompressor() func(r io.Reader) io.ReadCloser

StdFlateDecompressor returns a pooled standard library zip.Decompressor.

type Archiver Uses

type Archiver struct {
    // contains filtered or unexported fields
}

Archiver is an opinionated Zip archiver.

Only regular files, symlinks and directories are supported. Only files that are children of the specified chroot directory will be archived.

Access permissions, ownership (unix) and modification times are preserved.

func NewArchiver Uses

func NewArchiver(w io.Writer, chroot string, opts ...ArchiverOption) (*Archiver, error)

NewArchiver returns a new Archiver.

func (*Archiver) Archive Uses

func (a *Archiver) Archive(files map[string]os.FileInfo) (err error)

Archive calls ArchiveWithContext with a background context.

func (*Archiver) ArchiveWithContext Uses

func (a *Archiver) ArchiveWithContext(ctx context.Context, files map[string]os.FileInfo) (err error)

ArchiveWithContext archives all files, symlinks and directories.

func (*Archiver) Close Uses

func (a *Archiver) Close() error

Close closes the underlying ZipWriter.

func (*Archiver) RegisterCompressor Uses

func (a *Archiver) RegisterCompressor(method uint16, comp zip.Compressor)

RegisterCompressor registers custom compressors for a specified method ID. The common methods Store and Deflate are built in.

func (*Archiver) Written Uses

func (a *Archiver) Written() (bytes, entries int64)

Written returns how many bytes and entries have been written to the archive. Written can be called whilst archiving is in progress.

type ArchiverOption Uses

type ArchiverOption func(*archiverOptions) error

ArchiverOption is an option used when creating an archiver.

func WithArchiverConcurrency Uses

func WithArchiverConcurrency(n int) ArchiverOption

WithArchiverConcurrency will set the maximum number of files to be compressed concurrently. The default is GOMAXPROCS.

func WithArchiverMethod Uses

func WithArchiverMethod(method uint16) ArchiverOption

WithArchiverMethod sets the zip method to be used for compressible files.

func WithStageDirectory Uses

func WithStageDirectory(dir string) ArchiverOption

WithStageDirectory sets the directory to be used to stage compressed files before they're written to the archive. The default is the directory to be archived.

type Extractor Uses

type Extractor struct {
    // contains filtered or unexported fields
}

Extractor is an opinionated Zip file extractor.

Files are extracted in parallel. Only regular files, symlinks and directories are supported. Files can only be extracted to the specified chroot directory.

Access permissions, ownership (unix) and modification times are preserved.

func NewExtractor Uses

func NewExtractor(filename string, chroot string, opts ...ExtractorOption) (*Extractor, error)

NewExtractor returns a new extractor.

func (*Extractor) Close Uses

func (e *Extractor) Close() error

Close closes the underlying ZipReader.

func (*Extractor) Extract Uses

func (e *Extractor) Extract() error

Extract calls ExtractWithContext with a background context.

func (*Extractor) ExtractWithContext Uses

func (e *Extractor) ExtractWithContext(ctx context.Context) (err error)

ExtractWithContext extracts files, creates symlinks and directories from the archive.

func (*Extractor) Files Uses

func (e *Extractor) Files() []*zip.File

Files returns the file within the archive.

func (*Extractor) RegisterDecompressor Uses

func (e *Extractor) RegisterDecompressor(method uint16, dcomp zip.Decompressor)

RegisterDecompressor allows custom decompressors for a specified method ID. The common methods Store and Deflate are built in.

func (*Extractor) Written Uses

func (e *Extractor) Written() (bytes, entries int64)

Written returns how many bytes and entries have been written to disk. Written can be called whilst extraction is in progress.

type ExtractorOption Uses

type ExtractorOption func(*extractorOptions) error

ExtractorOption is an option used when creating an extractor.

func WithExtractorChownErrorHandler Uses

func WithExtractorChownErrorHandler(fn func(name string, err error) error) ExtractorOption

WithExtractorChownErrorHandler sets an error handler to be called if errors are encountered when trying to preserve ownership of extracted files. Returning nil will continue extraction, returning any error will cause Extract() to error.

func WithExtractorConcurrency Uses

func WithExtractorConcurrency(n int) ExtractorOption

WithExtractorConcurrency will set the maximum number of files being extracted concurrently. The default is GOMAXPROCS.

Directories

PathSynopsis
internal/filepool
internal/zipPackage zip provides support for reading and writing ZIP archives.

Package fastzip imports 23 packages (graph). Updated 2019-12-05. Refresh now. Tools for package owners.