ziptest

package
v0.0.0-...-0bbbf19 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileInfoHeader

func FileInfoHeader(t testing.TB, fi fs.FileInfo) *zip.FileHeader

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.

func NewReader

func NewReader(t testing.TB, r io.ReaderAt, size int64) *zip.Reader

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 OpenReader

func OpenReader(t testing.TB, name string) *zip.ReadCloser

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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