ziputil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MulanPSL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1 << (10 * iota)
	MB
	GB
)

Variables

This section is empty.

Functions

func GetLinesFromZip

func GetLinesFromZip(zipPath string, paths ...string) (map[string]string, error)

GetLinesFromZip extracts select paths for the given archive and returns a set of string contents for each path.

func GetTextFromZip

func GetTextFromZip(zipPath string, path string) (string, error)

GetTextFromZip get content by path from given archive file

func GlobMatch

func GlobMatch(pattern, path string) bool

func ReadFileContext

func ReadFileContext(file *zip.File) string

func SafeCopy

func SafeCopy(dst io.Writer, src io.Reader) error

func TraverseFilesInZip

func TraverseFilesInZip(zipPath string, visitor func(*zip.File) error, targetPaths ...string) error

TraverseFilesInZip enumerates all paths stored within a zip archive using the visitor pattern.

Types

type FileManifest

type FileManifest map[string]os.FileInfo

FileManifest is a collection of paths and their file metadata.

func ResolveFileManifest

func ResolveFileManifest(path string) (FileManifest, error)

ResolveFileManifest creates and returns a new ZipFileManifest populated with path and metadata from the given zip archive path.

func (FileManifest) Add

func (f FileManifest) Add(path string, info os.FileInfo)

func (FileManifest) GlobMatch

func (f FileManifest) GlobMatch(patterns ...string) []string

type ZipReadCloser

type ZipReadCloser struct {
	*zip.Reader
	io.Closer
}

ZipReadCloser zip Reader and Closer

func OpenZip

func OpenZip(path string) (*ZipReadCloser, error)

OpenZip provides a ZipReadCloser for the given filepath.

Jump to

Keyboard shortcuts

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