Documentation ¶
Overview ¶
Package zip implements functions for jarcat that manipulate .zip files.
Index ¶
- type File
- func (f *File) AddFiles(in string) error
- func (f *File) AddInitPyFiles() error
- func (f *File) AddManifest(mainClass string) error
- func (f *File) AddZipFile(filepath string) error
- func (f *File) Close()
- func (f *File) HasExistingFile(name string) bool
- func (f *File) StripBytecodeTimestamp(filename string, contents []byte) error
- func (f *File) WriteDir(filename string) error
- func (f *File) WriteFile(filename string, data []byte, mode os.FileMode) error
- func (f *File) WritePreamble(preamble []byte) error
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 ¶
NewFile constructs and returns a new File.
func (*File) AddFiles ¶
AddFiles walks the given directory and adds any zip files (determined by suffix) that it finds within.
func (*File) AddInitPyFiles ¶
AddInitPyFiles adds an __init__.py file to every directory in the zip file that doesn't already have one.
func (*File) AddManifest ¶
AddManifest adds a manifest to the given zip writer with a Main-Class entry (and a couple of others)
func (*File) AddZipFile ¶
AddZipFile copies the contents of a zip file into the new zipfile.
func (*File) HasExistingFile ¶
HasExistingFile returns true if the writer has already written the given file.
func (*File) StripBytecodeTimestamp ¶
StripBytecodeTimestamp strips a timestamp from a .pyc or .pyo file. This is important so our output is deterministic.
func (*File) WriteDir ¶
WriteDir writes a directory entry to the writer.
func (*File) WriteFile ¶
WriteFile writes a complete file to the writer.