go/src/archive/zip/reader.go

var zipinsecurepath

var ErrFormat

var ErrAlgorithm

var ErrChecksum

var ErrInsecurePath

type Reader

type ReadCloser

type File

// OpenReader will open the Zip file specified by name and return a ReadCloser.
//
// If any file inside the archive uses a non-local name
// (as defined by [filepath.IsLocal]) or a name containing backslashes
// and the GODEBUG environment variable contains `zipinsecurepath=0`,
// OpenReader returns the reader with an ErrInsecurePath error.
// A future version of Go may introduce this behavior by default.
// Programs that want to accept non-local names can ignore
// the ErrInsecurePath error and use the returned reader.
func OpenReader(name string) (*ReadCloser, error) {}

// NewReader returns a new [Reader] reading from r, which is assumed to
// have the given size in bytes.
//
// If any file inside the archive uses a non-local name
// (as defined by [filepath.IsLocal]) or a name containing backslashes
// and the GODEBUG environment variable contains `zipinsecurepath=0`,
// NewReader returns the reader with an [ErrInsecurePath] error.
// A future version of Go may introduce this behavior by default.
// Programs that want to accept non-local names can ignore
// the [ErrInsecurePath] error and use the returned reader.
func NewReader(r io.ReaderAt, size int64) (*Reader, error) {}

func (r *Reader) init(rdr io.ReaderAt, size int64) error {}

// 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.
func (r *Reader) RegisterDecompressor(method uint16, dcomp Decompressor) {}

func (r *Reader) decompressor(method uint16) Decompressor {}

// Close closes the Zip file, rendering it unusable for I/O.
func (rc *ReadCloser) Close() error {}

// DataOffset returns the offset of the file's possibly-compressed
// data, relative to the beginning of the zip file.
//
// Most callers should instead use [File.Open], which transparently
// decompresses data and verifies checksums.
func (f *File) DataOffset() (offset int64, err error) {}

// Open returns a [ReadCloser] that provides access to the [File]'s contents.
// Multiple files may be read concurrently.
func (f *File) Open() (io.ReadCloser, error) {}

// OpenRaw returns a [Reader] that provides access to the [File]'s contents without
// decompression.
func (f *File) OpenRaw() (io.Reader, error) {}

type dirReader

func (r *dirReader) Read([]byte) (int, error) {}

func (r *dirReader) Close() error {}

type checksumReader

func (r *checksumReader) Stat() (fs.FileInfo, error) {}

func (r *checksumReader) Read(b []byte) (n int, err error) {}

func (r *checksumReader) Close() error {}

// findBodyOffset does the minimum work to verify the file has a header
// and returns the file body offset.
func (f *File) findBodyOffset() (int64, error) {}

// readDirectoryHeader attempts to read a directory header from r.
// It returns io.ErrUnexpectedEOF if it cannot read a complete header,
// and ErrFormat if it doesn't find a valid header signature.
func readDirectoryHeader(f *File, r io.Reader) error {}

func readDataDescriptor(r io.Reader, f *File) error {}

func readDirectoryEnd(r io.ReaderAt, size int64) (dir *directoryEnd, baseOffset int64, err error) {}

// findDirectory64End tries to read the zip64 locator just before the
// directory end and returns the offset of the zip64 directory end if
// found.
func findDirectory64End(r io.ReaderAt, directoryEndOffset int64) (int64, error) {}

// readDirectory64End reads the zip64 directory end and updates the
// directory end with the zip64 directory end values.
func readDirectory64End(r io.ReaderAt, offset int64, d *directoryEnd) (err error) {}

func findSignatureInBlock(b []byte) int {}

type readBuf

func (b *readBuf) uint8() uint8 {}

func (b *readBuf) uint16() uint16 {}

func (b *readBuf) uint32() uint32 {}

func (b *readBuf) uint64() uint64 {}

func (b *readBuf) sub(n int) readBuf {}

type fileListEntry

type fileInfoDirEntry

func (f *fileListEntry) stat() (fileInfoDirEntry, error) {}

// Only used for directories.
func (f *fileListEntry) Name() string      {}

func (f *fileListEntry) Size() int64       {}

func (f *fileListEntry) Mode() fs.FileMode {}

func (f *fileListEntry) Type() fs.FileMode {}

func (f *fileListEntry) IsDir() bool       {}

func (f *fileListEntry) Sys() any          {}

func (f *fileListEntry) ModTime() time.Time {}

func (f *fileListEntry) Info() (fs.FileInfo, error) {}

func (f *fileListEntry) String() string {}

// toValidName coerces name to be a valid name for fs.FS.Open.
func toValidName(name string) string {}

func (r *Reader) initFileList() {}

func fileEntryCompare(x, y string) int {}

// 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.
func (r *Reader) Open(name string) (fs.File, error) {}

func split(name string) (dir, elem string, isDir bool) {}

var dotFile

func (r *Reader) openLookup(name string) *fileListEntry {}

func (r *Reader) openReadDir(dir string) []fileListEntry {}

type openDir

func (d *openDir) Close() error               {}

func (d *openDir) Stat() (fs.FileInfo, error) {}

func (d *openDir) Read([]byte) (int, error) {}

func (d *openDir) ReadDir(count int) ([]fs.DirEntry, error) {}