archive

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const GzipMaxLength = math.MaxUint32
View Source
const GzipWrapperLength = 18

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive interface {
	Entries() []Entry                 // List of all the archived file entries.
	Entry(path string) (Entry, error) // Gets the entry at the given `path`.
	Close()
}

Represents an immutable archive.

func NewExplodedArchive

func NewExplodedArchive(directory string) Archive

func NewGoZIPArchive

func NewGoZIPArchive(zip *zip.Reader, closer func() error, minimizeReads bool) Archive

type ArchiveFactory

type ArchiveFactory interface {
	Open(filepath string, password string) (Archive, error)                                             // Opens an archive from a local [file].
	OpenBytes(data []byte, password string) (Archive, error)                                            // Opens an archive from a [data] slice.
	OpenReader(reader ReaderAtCloser, size int64, password string, minimizeReads bool) (Archive, error) // Opens an archive from a reader.
}

type CompressionMethod added in v0.5.0

type CompressionMethod uint16
const (
	CompressionMethodStore   CompressionMethod = CompressionMethod(zip.Store)
	CompressionMethodDeflate CompressionMethod = CompressionMethod(zip.Deflate)
)

type DefaultArchiveFactory

type DefaultArchiveFactory struct {
	// contains filtered or unexported fields
}

func NewArchiveFactory

func NewArchiveFactory() DefaultArchiveFactory

func (DefaultArchiveFactory) Open

func (e DefaultArchiveFactory) Open(filepath string, password string) (Archive, error)

Open implements ArchiveFactory

func (DefaultArchiveFactory) OpenBytes

func (e DefaultArchiveFactory) OpenBytes(data []byte, password string) (Archive, error)

OpenBytes implements ArchiveFactory

func (DefaultArchiveFactory) OpenReader

func (e DefaultArchiveFactory) OpenReader(reader ReaderAtCloser, size int64, password string, minimizeReads bool) (Archive, error)

OpenBytes implements ArchiveFactory

type Entry

type Entry interface {
	Path() string                                              // Absolute path to the entry in the archive.
	Length() uint64                                            // Uncompressed data length.
	CompressedLength() uint64                                  // Compressed data length.
	CompressedAs(compressionMethod CompressionMethod) bool     // Whether the entry is compressed using the given method.
	Read(start int64, end int64) ([]byte, error)               // Reads the whole content of this entry, or a portion when [start] or [end] are specified.
	Stream(w io.Writer, start int64, end int64) (int64, error) // Streams the whole content of this entry to a writer, or a portion when [start] or [end] are specified.

	StreamCompressed(w io.Writer) (int64, error)     // Streams the compressed content of this entry to a writer.
	StreamCompressedGzip(w io.Writer) (int64, error) // Streams the compressed content of this entry to a writer in a GZIP container.
	ReadCompressed() ([]byte, error)                 // Reads the compressed content of this entry.
	ReadCompressedGzip() ([]byte, error)             // Reads the compressed content of this entry inside a GZIP container.

}

Holds an archive entry's metadata.

type ReaderAtCloser

type ReaderAtCloser interface {
	io.Closer
	io.ReaderAt
}

Jump to

Keyboard shortcuts

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