ar

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	Name    string
	ModTime time.Time
	Uid     int
	Gid     int
	Mode    int64
	Size    int64
}

type Reader

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

func NewReader

func NewReader(r io.Reader) (*Reader, error)

Copies read data to r. Strips the global ar header.

func (*Reader) Next

func (rd *Reader) Next() (*Header, error)

Call Next() to skip to the next file in the archive file. Returns a Header which contains the metadata about the file in the archive.

func (*Reader) Read

func (rd *Reader) Read(b []byte) (n int, err error)

Read data from the current entry in the archive.

type Writer

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

Writer provides sequential writing of an ar archive. An ar archive is sequence of header file pairs Call WriteHeader to begin writing a new file, then call Write to supply the file's data

Example: archive := ar.NewWriter(writer) archive.WriteGlobalHeader() header := new(ar.Header) header.Size = 15 // bytes

if err := archive.WriteHeader(header); err != nil {
	return err
}

io.Copy(archive, data)

func NewWriter

func NewWriter(w io.Writer) *Writer

Create a new ar writer that writes to w

func (*Writer) Write

func (aw *Writer) Write(b []byte) (n int, err error)

Writes to the current entry in the ar archive Returns ErrWriteTooLong if more than header.Size bytes are written after a call to WriteHeader

func (*Writer) WriteGlobalHeader

func (aw *Writer) WriteGlobalHeader() error

func (*Writer) WriteHeader

func (aw *Writer) WriteHeader(hdr *Header) error

Writes the header to the underlying writer and prepares to receive the file payload

Jump to

Keyboard shortcuts

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