cab

package
v0.0.0-...-b62abdc Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cabfile provides a bare minimum implementation of a parser for the Microsoft Cabinet file format. Its goal is to support the feature set of Cabinet files produced by gcab for the LVFS project.

Normative references for this implementation are MS-CAB for the Cabinet file format and MS-MCI for the Microsoft ZIP Compression and Decompression Data Structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExactReader

func ExactReader(r io.Reader, n int64) io.ReadCloser

ExactReader returns a Reader that reads from r but stops with EOF after n bytes. It returns ErrUnexpectedEOF if the underlying reader returns EOF before n bytes. The underlying implementation is a *ExactReader.

Types

type Cabinet

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

Cabinet provides read-only access to Microsoft Cabinet files.

func New

func New(r io.ReadSeeker) (*Cabinet, error)

New returns a new Cabinet with the header structures parsed and sanity checked.

func (*Cabinet) Content

func (c *Cabinet) Content(name string) (io.Reader, error)

Content returns the content of the file specified by its filename as an io.Reader. Note that the entire folder which contains the file in question is decompressed for every file request.

func (*Cabinet) FileList

func (c *Cabinet) FileList() []string

FileList returns the list of filenames in the Cabinet file.

func (*Cabinet) Next

func (c *Cabinet) Next() (*Header, error)

func (*Cabinet) Read

func (c *Cabinet) Read(p []byte) (n int, err error)

type ExactReaderImpl

type ExactReaderImpl struct {
	R io.Reader // underlying reader
	N int64     // max bytes remaining
}

A ExactReaderImpl reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining. Read returns EOF when N <= 0 or when the underlying R returns EOF.

func (*ExactReaderImpl) Close

func (e *ExactReaderImpl) Close() error

func (*ExactReaderImpl) Read

func (e *ExactReaderImpl) Read(p []byte) (n int, err error)
type Header struct {
	// Name of the file including path
	Name string
	// Time the file was created
	CreateTime time.Time
	// The file size in bytes
	Size uint32
}

Jump to

Keyboard shortcuts

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