zip

package
v2.47.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package zip provide convenience utilities to work with config files.

Index

Constants

View Source
const (
	DefaultFileMode = 0o644
)

Variables

View Source
var ErrFlushed = errors.New("zipped file: already flushed")

Functions

func UnPack

func UnPack(zipFile *proto.ZippedFile) ([]*proto.File, error)

func UnPackWithDirCheck added in v2.46.7

func UnPackWithDirCheck(zipFile *proto.ZippedFile, allowedDirs map[string]struct{}) ([]*proto.File, error)

Types

type FileReaderCallback

type FileReaderCallback = func(err error, path string, mode os.FileMode, r io.Reader) bool

type Reader

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

func NewReader

func NewReader(p *proto.ZippedFile) (*Reader, error)

NewReader returns a Reader to help with extracting the files from the provided ZippedFile proto.

func NewReaderFromPayloads

func NewReaderFromPayloads(content []byte, prefix, cs string) (*Reader, error)

NewReaderFromPayloads returns a Reader to help with extracting the provided zipped content

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Prefix

func (r *Reader) Prefix() string

func (*Reader) RangeFileReaders

func (r *Reader) RangeFileReaders(callback FileReaderCallback)

RangeFileReaders calls f sequentially for each file in the zip archive. If f returns false, range stops the iteration.

type Writer

type Writer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Writer is a helper for building the proto ZippedFile for sending with multiple file contents. Uses in memory bytes.Buffer, should be extended if larger file content is expected.

func NewWriter

func NewWriter(prefix string) (*Writer, error)

NewWriter returns a writer for to create the ZippedFile proto.

func (*Writer) Add

func (z *Writer) Add(name string, mode os.FileMode, r io.Reader) error

func (*Writer) AddFile

func (z *Writer) AddFile(fullPath string) error

func (*Writer) FileLen

func (z *Writer) FileLen() int

func (*Writer) Payloads

func (z *Writer) Payloads() ([]byte, string, string, error)

Payloads returns the content, prefix, and checksum for the files written to the writer.

func (*Writer) Proto

func (z *Writer) Proto() (*proto.ZippedFile, error)

Jump to

Keyboard shortcuts

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