rardecode

package module
v0.0.0-...-3815c0e Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: BSD-2-Clause Imports: 20 Imported by: 0

README

rardecode

A go package for reading RAR archives.

Snapshot of the experimental branch of https://github.com/nwaples/rardecode plus fixing of linter complaints

git revision 6fefacfc63d20d164fb7884fb94c4a9d921f97e7

Aug 8 15:05:48 2021 +1000

Documentation

Index

Constants

View Source
const (
	HostOSUnknown = 0
	HostOSMSDOS   = 1
	HostOSOS2     = 2
	HostOSWindows = 3
	HostOSUnix    = 4
	HostOSMacOS   = 5
	HostOSBeOS    = 6
)

FileHeader HostOS types

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	FileHeader
	// contains filtered or unexported fields
}

File represents a file in a RAR archive

func List

func List(name string, opts ...Option) ([]*File, error)

List returns a list of File's in the RAR archive specified by name.

func (*File) Open

func (f *File) Open() (io.ReadCloser, error)

Open returns an io.ReadCloser that provides access to the File's contents. Open is not supported on Solid File's as their contents depend on the decoding of the preceding files in the archive. Use OpenReader and Next to access Solid file contents instead.

type FileHeader

type FileHeader struct {
	Name             string    // file name using '/' as the directory separator
	Attributes       int64     // Host OS specific file attributes
	PackedSize       int64     // packed file size (or first block if the file spans volumes)
	UnPackedSize     int64     // unpacked file size
	ModificationTime time.Time // modification time (non-zero if set)
	CreationTime     time.Time // creation time (non-zero if set)
	AccessTime       time.Time // access time (non-zero if set)
	Version          int       // file version
	HostOS           byte      // Host OS the archive was created on
	IsDir            bool      // is a directory
	Solid            bool      // is a solid file
	UnKnownSize      bool      // unpacked file size is not known
}

FileHeader represents a single file in a RAR archive.

func (*FileHeader) Mode

func (f *FileHeader) Mode() os.FileMode

Mode returns an os.FileMode for the file, calculated from the Attributes field.

type Option

type Option func(*option)

An Option is used for optional archive extraction settings.

func BufferSize

func BufferSize(size int) Option

BufferSize sets the size of the bufio.Reader used in reading the archive.

func FileSystem

func FileSystem(fs fs.FS) Option

FileSystem sets the fs.FS to be used for opening archive volumes.

func Password

func Password(pass string) Option

Password sets the password to use for decrypting archives.

type ReadCloser

type ReadCloser struct {
	Reader
}

ReadCloser is a Reader that allows closing of the rar archive.

func OpenReader

func OpenReader(name string, opts ...Option) (*ReadCloser, error)

OpenReader opens a RAR archive specified by the name and returns a ReadCloser.

func (*ReadCloser) Close

func (rc *ReadCloser) Close() error

Close closes the rar file.

type Reader

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

Reader provides sequential access to files in a RAR archive.

func NewReader

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

NewReader creates a Reader reading from r. NewReader only supports single volume archives. Multi-volume archives must use OpenReader.

func (*Reader) Next

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

Next advances to the next file in the archive.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read reads from the current file in the RAR archive.

func (*Reader) WriteTo

func (r *Reader) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo.

Jump to

Keyboard shortcuts

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