zip

package
v2.33.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

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)

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