Documentation
¶
Index ¶
- Constants
- func FindDirectory(r io.ReaderAt, size int64) (int64, error)
- func ZipToTar(r *os.File, w io.Writer) error
- type Directory
- func (d *Directory) AddFile(f *File) (*File, error)
- func (d *Directory) GetOriginalDirectory(trim bool) (cdEntries, endOfDir []byte, err error)
- func (d *Directory) Mangle(callback MangleFunc) (*Mangler, error)
- func (d *Directory) NewFile(name string, extra, contents []byte, w io.Writer, mtime time.Time, ...) (*File, error)
- func (d *Directory) NextFileOffset() (int64, error)
- func (d *Directory) Truncate(n int, body, dir io.Writer) error
- func (d *Directory) WriteDirectory(wcd, weod io.Writer, forceZip64 bool) error
- type File
- func (f *File) Digest(hash crypto.Hash) ([]byte, error)
- func (f *File) Dump(w io.Writer) (int64, error)
- func (f *File) GetDataDescriptor() ([]byte, error)
- func (f *File) GetDirectoryHeader() ([]byte, error)
- func (f *File) GetLocalHeader() ([]byte, error)
- func (f *File) GetTotalSize() (int64, error)
- func (f *File) ModTime() time.Time
- func (f *File) Open() (io.ReadCloser, error)
- func (f *File) OpenAndTeeRaw(sink io.Writer) (*Reader, error)
- type MangleFile
- type MangleFunc
- type Mangler
- type Reader
Constants ¶
const ( TarMemberCD = "zipdir.bin" TarMemberZip = "contents.zip" )
Variables ¶
This section is empty.
Functions ¶
func FindDirectory ¶
Return the offset of the zip central directory
Types ¶
type Directory ¶
type Directory struct {
File []*File
Size int64
DirLoc int64
// contains filtered or unexported fields
}
func ReadStream ¶
Read a zip from a stream, using a separate copy of the central directory. Contents must be read in zip order or an error will be raised.
func ReadWithDirectory ¶
Read a zip from a ReaderAt, with a separate copy of the central directory
func ReadZipTar ¶
Read a tar stream produced by ZipToTar and return the zip directory. Files must be read from the zip in order or an error will be raised.
func (*Directory) AddFile ¶
Add a file to the central directory. Its contents are assumed to be already located after the last added file.
func (*Directory) GetOriginalDirectory ¶
Get the original central directory and end-of-directory from a previously-read file.
If trim is true, then the end-of-directory will be updated to skip over any non-ZIP data between the last file's contents and the first central directory entry.
func (*Directory) Mangle ¶
func (d *Directory) Mangle(callback MangleFunc) (*Mangler, error)
Walk all the files in the directory in-order, invoking a callback that can decide whether to keep or discard each one. Returns a Mangler that can be used to add more files and eventually produce a binary patch against the original zip.
func (*Directory) NextFileOffset ¶
Get the offset immediately following the last file's contents. This is the same as DirLoc unless there is non-zip data in between.
func (*Directory) Truncate ¶
Serialize a zip file with all of the files up to, but not including, the given index. The contents and central directory are written to separate writers, which may be the same writer.
func (*Directory) WriteDirectory ¶
Serialize a zip central directory to file. The file entries will be written to wcd, and the end-of-directory markers will be written to weod.
If forceZip64 is true then a ZIP64 end-of-directory marker will always be written; otherwise it is only done if ZIP64 features are required.
type File ¶
type File struct {
CreatorVersion uint16
ReaderVersion uint16
Flags uint16
Method uint16
ModifiedTime uint16
ModifiedDate uint16
CRC32 uint32
CompressedSize uint64
UncompressedSize uint64
Name string
Extra []byte
Comment []byte
InternalAttrs uint16
ExternalAttrs uint32
Offset uint64
// contains filtered or unexported fields
}
func (*File) GetDataDescriptor ¶
func (*File) GetDirectoryHeader ¶
func (*File) GetLocalHeader ¶
func (*File) GetTotalSize ¶
type MangleFile ¶
type MangleFile struct {
File
// contains filtered or unexported fields
}
type MangleFunc ¶
type MangleFunc func(*MangleFile) error