Namespace: go.std.archive.zip
v1.0Contents
Summary
Provides a low-level interface to the archive/zip package.
Package zip provides support for reading and writing ZIP archives.
See: https://www.pkware.com/appnote
This package does not support disk spanning.
A note about ZIP64:
To be backwards compatible the FileHeader has both 32 and 64 bit Size
fields. The 64 bit fields will always contain the correct value and
for normal archives both fields will be the same. For files requiring
the ZIP64 format the 32 bit fields will be 0xffffffff and the 64 bit
fields must be used instead.
Index
- *Compressor
- *Decompressor
- *File
- *FileHeader
- *ReadCloser
- *Reader
- *Writer
- Compressor
- Decompressor
- Deflate
- ErrAlgorithm
- ErrChecksum
- ErrFormat
- File
- FileHeader
- FileInfoHeader
- NewReader
- NewWriter
- OpenReader
- ReadCloser
- Reader
- RegisterCompressor
- RegisterDecompressor
- Store
- Writer
- arrayOfCompressor
- arrayOfDecompressor
- arrayOfFile
- arrayOfFileHeader
- arrayOfReadCloser
- arrayOfReader
- arrayOfWriter
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
Deflate
Int v1.0DEFLATE compressed
-
Store
Int v1.0no compression
Variables
-
ErrAlgorithm
Var v1.0 -
ErrChecksum
Var v1.0 -
ErrFormat
Var v1.0
Functions, Macros, and Special Forms
-
FileInfoHeader
Function v1.0(FileInfoHeader fi)
FileInfoHeader creates a partially-populated FileHeader from an
fs.FileInfo.
Because fs.FileInfo's Name method returns only the base name of
the file it describes, it may be necessary to modify the Name field
of the returned header to provide the full path name of the file.
If compression is desired, callers should set the FileHeader.Method
field; it is unset by default.
Go input arguments: (fi io/fs.FileInfo)
Go returns: (*FileHeader, error)
Joker input arguments: [^go.std.io.fs/FileInfo fi]
Joker returns: [^*FileHeader, ^Error] -
NewReader
Function v1.0(NewReader r size)
NewReader returns a new Reader reading from r, which is assumed to
have the given size in bytes.
Go input arguments: (r io.ReaderAt, size int64)
Go returns: (*Reader, error)
Joker input arguments: [^go.std.io/ReaderAt r, ^BigInt size]
Joker returns: [^*Reader, ^Error] -
NewWriter
Function v1.0(NewWriter w)
NewWriter returns a new Writer writing a zip file to w.
Go input arguments: (w io.Writer)
Go returns: *Writer
Joker input arguments: [^go.std.io/Writer w]
Joker returns: ^*Writer -
OpenReader
Function v1.0(OpenReader name)
OpenReader will open the Zip file specified by name and return a ReadCloser.
Go input arguments: (name string)
Go returns: (*ReadCloser, error)
Joker input arguments: [^String name]
Joker returns: [^*ReadCloser, ^Error] -
RegisterCompressor
Function v1.0(RegisterCompressor method comp)
RegisterCompressor registers custom compressors for a specified method ID.
The common methods Store and Deflate are built in.
Go input arguments: (method uint16, comp Compressor)
Joker input arguments: [^Int method, ^Compressor comp] -
RegisterDecompressor
Function v1.0(RegisterDecompressor method dcomp)
RegisterDecompressor allows custom decompressors for a specified method ID.
The common methods Store and Deflate are built in.
Go input arguments: (method uint16, dcomp Decompressor)
Joker input arguments: [^Int method, ^Decompressor dcomp]
Types
-
*Compressor
Concrete Type v1.0A Compressor returns a new compressing writer, writing to w.
The WriteCloser's Close method must be used to flush pending data to w.
The Compressor itself must be safe to invoke from multiple goroutines
simultaneously, but each returned writer will be used only by
one goroutine at a time.
-
*Decompressor
Concrete Type v1.0A Decompressor returns a new decompressing reader, reading from r.
The ReadCloser's Close method must be used to release associated resources.
The Decompressor itself must be safe to invoke from multiple goroutines
simultaneously, but each returned reader will be used only by
one goroutine at a time.
-
*File
Concrete Type v1.0A File is a single file in a ZIP archive.
The file information is in the embedded FileHeader.
The file content can be accessed by calling Open.
-
DataOffset
Receiver for *File v1.0([])
DataOffset returns the offset of the file's possibly-compressed
data, relative to the beginning of the zip file.
Most callers should instead use Open, which transparently
decompresses data and verifies checksums.
-
FileInfo
Receiver for *File v1.0([])
FileInfo returns an fs.FileInfo for the FileHeader.
-
ModTime
Receiver for *File v1.0([])
ModTime returns the modification time in UTC using the legacy
ModifiedDate and ModifiedTime fields.
Deprecated: Use Modified instead.
-
Mode
Receiver for *File v1.0([])
Mode returns the permission and mode bits for the FileHeader.
-
Open
Receiver for *File v1.0([])
Open returns a ReadCloser that provides access to the File's contents.
Multiple files may be read concurrently.
-
OpenRaw
Receiver for *File v1.0([])
OpenRaw returns a Reader that provides access to the File's contents without
decompression.
-
SetModTime
Receiver for *File v1.0([t])
SetModTime sets the Modified, ModifiedTime, and ModifiedDate fields
to the given time in UTC.
Deprecated: Use Modified instead.
-
SetMode
Receiver for *File v1.0([mode])
SetMode changes the permission and mode bits for the FileHeader.
-
*FileHeader
Concrete Type v1.0FileHeader describes a file within a zip file.
See the zip spec for details.
-
FileInfo
Receiver for *FileHeader v1.0([])
FileInfo returns an fs.FileInfo for the FileHeader.
-
ModTime
Receiver for *FileHeader v1.0([])
ModTime returns the modification time in UTC using the legacy
ModifiedDate and ModifiedTime fields.
Deprecated: Use Modified instead.
-
Mode
Receiver for *FileHeader v1.0([])
Mode returns the permission and mode bits for the FileHeader.
-
SetModTime
Receiver for *FileHeader v1.0([t])
SetModTime sets the Modified, ModifiedTime, and ModifiedDate fields
to the given time in UTC.
Deprecated: Use Modified instead.
-
SetMode
Receiver for *FileHeader v1.0([mode])
SetMode changes the permission and mode bits for the FileHeader.
-
*ReadCloser
Concrete Type v1.0A ReadCloser is a Reader that must be closed when no longer needed.
-
Close
Receiver for *ReadCloser v1.0([])
Close closes the Zip file, rendering it unusable for I/O.
-
Open
Receiver for *ReadCloser v1.0([name])
Open opens the named file in the ZIP archive,
using the semantics of fs.FS.Open:
paths are always slash separated, with no
leading / or ../ elements.
-
RegisterDecompressor
Receiver for *ReadCloser v1.0([method dcomp])
RegisterDecompressor registers or overrides a custom decompressor for a
specific method ID. If a decompressor for a given method is not found,
Reader will default to looking up the decompressor at the package level.
-
*Reader
Concrete Type v1.0A Reader serves content from a ZIP archive.
-
Open
Receiver for *Reader v1.0([name])
Open opens the named file in the ZIP archive,
using the semantics of fs.FS.Open:
paths are always slash separated, with no
leading / or ../ elements.
-
RegisterDecompressor
Receiver for *Reader v1.0([method dcomp])
RegisterDecompressor registers or overrides a custom decompressor for a
specific method ID. If a decompressor for a given method is not found,
Reader will default to looking up the decompressor at the package level.
-
*Writer
Concrete Type v1.0Writer implements a zip file writer.
-
Close
Receiver for *Writer v1.0([])
Close finishes writing the zip file by writing the central directory.
It does not close the underlying writer.
-
Copy
Receiver for *Writer v1.0([f])
Copy copies the file f (obtained from a Reader) into w. It copies the raw
form directly bypassing decompression, compression, and validation.
-
Create
Receiver for *Writer v1.0([name])
Create adds a file to the zip file using the provided name.
It returns a Writer to which the file contents should be written.
The file contents will be compressed using the Deflate method.
The name must be a relative path: it must not start with a drive
letter (e.g. C:) or leading slash, and only forward slashes are
allowed. To create a directory instead of a file, add a trailing
slash to the name.
The file's contents must be written to the io.Writer before the next
call to Create, CreateHeader, or Close.
-
CreateHeader
Receiver for *Writer v1.0([fh])
CreateHeader adds a file to the zip archive using the provided FileHeader
for the file metadata. Writer takes ownership of fh and may mutate
its fields. The caller must not modify fh after calling CreateHeader.
This returns a Writer to which the file contents should be written.
The file's contents must be written to the io.Writer before the next
call to Create, CreateHeader, CreateRaw, or Close.
-
CreateRaw
Receiver for *Writer v1.0([fh])
CreateRaw adds a file to the zip archive using the provided FileHeader and
returns a Writer to which the file contents should be written. The file's
contents must be written to the io.Writer before the next call to Create,
CreateHeader, CreateRaw, or Close.
In contrast to CreateHeader, the bytes passed to Writer are not compressed.
-
Flush
Receiver for *Writer v1.0([])
Flush flushes any buffered data to the underlying writer.
Calling Flush is not normally necessary; calling Close is sufficient.
-
RegisterCompressor
Receiver for *Writer v1.0([method comp])
RegisterCompressor registers or overrides a custom compressor for a specific
method ID. If a compressor for a given method is not found, Writer will
default to looking up the compressor at the package level.
-
SetComment
Receiver for *Writer v1.0([comment])
SetComment sets the end-of-central-directory comment field.
It can only be called before Close.
-
SetOffset
Receiver for *Writer v1.0([n])
SetOffset sets the offset of the beginning of the zip data within the
underlying writer. It should be used when the zip data is appended to an
existing file, such as a binary executable.
It must be called before any data is written.
-
Compressor
Concrete Type v1.0A Compressor returns a new compressing writer, writing to w.
The WriteCloser's Close method must be used to flush pending data to w.
The Compressor itself must be safe to invoke from multiple goroutines
simultaneously, but each returned writer will be used only by
one goroutine at a time.
-
Decompressor
Concrete Type v1.0A Decompressor returns a new decompressing reader, reading from r.
The ReadCloser's Close method must be used to release associated resources.
The Decompressor itself must be safe to invoke from multiple goroutines
simultaneously, but each returned reader will be used only by
one goroutine at a time.
-
File
Concrete Type v1.0A File is a single file in a ZIP archive.
The file information is in the embedded FileHeader.
The file content can be accessed by calling Open.
-
FileHeader
Concrete Type v1.0FileHeader describes a file within a zip file.
See the zip spec for details.
-
ReadCloser
Concrete Type v1.0A ReadCloser is a Reader that must be closed when no longer needed.
-
Reader
Concrete Type v1.0A Reader serves content from a ZIP archive.
-
Writer
Concrete Type v1.0Writer implements a zip file writer.
-
arrayOfCompressor
Concrete Type v1.0A Compressor returns a new compressing writer, writing to w.
The WriteCloser's Close method must be used to flush pending data to w.
The Compressor itself must be safe to invoke from multiple goroutines
simultaneously, but each returned writer will be used only by
one goroutine at a time.
-
arrayOfDecompressor
Concrete Type v1.0A Decompressor returns a new decompressing reader, reading from r.
The ReadCloser's Close method must be used to release associated resources.
The Decompressor itself must be safe to invoke from multiple goroutines
simultaneously, but each returned reader will be used only by
one goroutine at a time.
-
arrayOfFile
Concrete Type v1.0A File is a single file in a ZIP archive.
The file information is in the embedded FileHeader.
The file content can be accessed by calling Open.
-
arrayOfFileHeader
Concrete Type v1.0FileHeader describes a file within a zip file.
See the zip spec for details.
-
arrayOfReadCloser
Concrete Type v1.0A ReadCloser is a Reader that must be closed when no longer needed.
-
arrayOfReader
Concrete Type v1.0A Reader serves content from a ZIP archive.
-
arrayOfWriter
Concrete Type v1.0Writer implements a zip file writer.