zip

package
v13.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package zip implements functions for jarcat that manipulate .zip files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {

	// Include and Exclude are prefixes of filenames to include or exclude from the zipfile.
	Include, Exclude []string
	// Strict controls whether we deny duplicate files or not.
	// Zipfiles can readily contain duplicates, if this is true we reject them unless they are identical.
	// If false we allow duplicates and leave it to someone else to handle.
	Strict bool
	// RenameDirs is a map of directories to rename, from the old name to the new one.
	RenameDirs map[string]string
	// StripPrefix is a prefix that is stripped off any files added with AddFiles.
	StripPrefix string
	// Suffix is the suffix of files that we include while scanning.
	Suffix []string
	// ExcludeSuffix is a list of suffixes that are excluded from the file scan.
	ExcludeSuffix []string
	// StoreSuffix is a list of file suffixes that will be stored instead of deflated.
	StoreSuffix []string
	// IncludeOther will make the file scan include other files that are not part of a zip file.
	IncludeOther bool
	// AddInitPy will make the writer add __init__.py files to all directories that don't already have one on close.
	AddInitPy bool
	// StripPy will strip .py files when there is a corresponding .pyc
	StripPy bool
	// DirEntries makes the writer add empty directory entries.
	DirEntries bool
	// Align aligns entries to a multiple of this many bytes.
	Align int
	// Prefix stores all files with this prefix.
	Prefix string
	// contains filtered or unexported fields
}

A File represents an output zipfile.

func NewFile

func NewFile(output string, strict bool) *File

NewFile constructs and returns a new File.

func (*File) AddFiles

func (f *File) AddFiles(in string) error

AddFiles walks the given directory and adds any zip files (determined by suffix) that it finds within.

func (*File) AddInitPyFiles

func (f *File) AddInitPyFiles() error

AddInitPyFiles adds an __init__.py file to every directory in the zip file that doesn't already have one.

func (*File) AddManifest

func (f *File) AddManifest(mainClass string) error

AddManifest adds a manifest to the given zip writer with a Main-Class entry (and a couple of others)

func (*File) AddZipFile

func (f *File) AddZipFile(filepath string) error

AddZipFile copies the contents of a zip file into the new zipfile.

func (*File) Close

func (f *File) Close()

Close must be called before the File is destroyed.

func (*File) HasExistingFile

func (f *File) HasExistingFile(name string) bool

HasExistingFile returns true if the writer has already written the given file.

func (*File) StripBytecodeTimestamp

func (f *File) StripBytecodeTimestamp(filename string, contents []byte) error

StripBytecodeTimestamp strips a timestamp from a .pyc or .pyo file. This is important so our output is deterministic.

func (*File) WriteDir

func (f *File) WriteDir(filename string) error

WriteDir writes a directory entry to the writer.

func (*File) WriteFile

func (f *File) WriteFile(filename string, data []byte, mode os.FileMode) error

WriteFile writes a complete file to the writer.

func (*File) WritePreamble

func (f *File) WritePreamble(preamble []byte) error

WritePreamble writes a preamble to the zipfile.

Jump to

Keyboard shortcuts

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