archive

package module
v0.0.0-...-3fd1cff Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2018 License: MIT Imports: 9 Imported by: 3

README

go-libarchive

Golang bindings for the libarchive library.

Acknowledgments

based on robxu9's go-libarchive

Documentation

Index

Constants

View Source
const (
	ARCHIVE_EOF    = C.ARCHIVE_EOF
	ARCHIVE_OK     = C.ARCHIVE_OK
	ARCHIVE_RETRY  = C.ARCHIVE_RETRY
	ARCHIVE_WARN   = C.ARCHIVE_WARN
	ARCHIVE_FAILED = C.ARCHIVE_FAILED
	ARCHIVE_FATAL  = C.ARCHIVE_FATAL
)

Variables

View Source
var (
	FileTypeRegFile = C.AE_IFREG
	FileTypeSymLink = C.AE_IFLNK
	FileTypeSocket  = C.AE_IFSOCK
	FileTypeCharDev = C.AE_IFCHR
	FileTypeBlkDev  = C.AE_IFBLK
	FileTypeDir     = C.AE_IFDIR
	FileTypeFIFO    = C.AE_IFIFO
)
View Source
var (
	ErrArchiveEOF   = io.EOF
	ErrArchiveFatal = errors.New("libarchive: FATAL [critical error, archive closing]")
)

Functions

This section is empty.

Types

type ArchiveEntry

type ArchiveEntry interface {
	// FileInfo describing archive_entry
	Stat() os.FileInfo
	// The name of the entry
	PathName() string
}

ArchiveEntry represents an libarchive archive_entry

type Reader

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

Reader represents libarchive archive

func NewReader

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

NewReader returns new Archive by calling archive_read_open

func (*Reader) Close

func (r *Reader) Close() error

Close closes the underlying libarchive archive calling archive read_cloe

func (*Reader) Free

func (r *Reader) Free() error

Free frees the resources the underlying libarchive archive is using calling archive_read_free

func (*Reader) Next

func (r *Reader) Next() (ArchiveEntry, error)

Next calls archive_read_next_header and returns an interpretation of the ArchiveEntry which is a wrapper around libarchive's archive_entry, or Err.

ErrArchiveEOF is returned when there is no more to be read from the archive

func (*Reader) Read

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

Read calls archive_read_data which reads the current archive_entry. It acts as io.Reader.Read in any other aspect

func (*Reader) Size

func (r *Reader) Size() int

Size returns compressed size of the current archive entry

type ReedSeeker

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

ReedSeeker represents libarchive archive

func NewReadSeeker

func NewReadSeeker(reader io.ReadSeeker) (r *ReedSeeker, err error)

NewReader returns new Archive by calling archive_read_open

func (*ReedSeeker) Close

func (r *ReedSeeker) Close() error

Close closes the underlying libarchive archive calling archive read_cloe

func (*ReedSeeker) Free

func (r *ReedSeeker) Free() error

Free frees the resources the underlying libarchive archive is using calling archive_read_free

func (*ReedSeeker) Next

func (r *ReedSeeker) Next() (ArchiveEntry, error)

Next calls archive_read_next_header and returns an interpretation of the ArchiveEntry which is a wrapper around libarchive's archive_entry, or Err.

ErrArchiveEOF is returned when there is no more to be read from the archive

func (*ReedSeeker) Read

func (r *ReedSeeker) Read(b []byte) (n int, err error)

Read calls archive_read_data which reads the current archive_entry. It acts as io.ReedSeeker.Read in any other aspect

func (*ReedSeeker) Seek

func (r *ReedSeeker) Seek(offset int64, whence int) (int64, error)

Seek sets the offset for the next Read to offset

func (*ReedSeeker) Size

func (r *ReedSeeker) Size() int

Size returns compressed size of the current archive entry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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