unrarwrapper

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 16 Imported by: 0

README

this go package implements extracting files from .rar archives. It requires unrar executable to be installed.

the code is based on github.com/kjk/lzmadec

API reference: https://pkg.golang.ir/github.com/ttys3/unrar-wrapper

Documentation

Overview

Package unrarwrapper implements extracting files from .rar archives. It requires [unrar](https://www.rarlab.com/rar_add.htm) executable to be installed.

the code is based on github.com/kjk/lzmadec

ref: http://blog.kowalczyk.info/article/g/Extracting-files-from-7z-archives-in-Go.html.

Index

Constants

View Source
const NormalSep = "\n"

Variables

View Source
var (
	// ErrUnRARNotAvailable is returned if unrar executable is not available
	ErrUnRARNotAvailable = errors.New("unrar executable not available")

	// ErrNoEntries is returned if the archive has no files
	ErrNoEntries = errors.New("no entries in rar file")
)

Functions

func SetUnRARPath

func SetUnRARPath(path string)

Types

type Archive

type Archive struct {
	Path          string
	Entries       []Entry
	IsMultiVolume bool
	Volumes       []string
	// contains filtered or unexported fields
}

Archive describes a single .rar archive

func NewArchive

func NewArchive(path string) (*Archive, error)

func NewEncryptedArchive

func NewEncryptedArchive(path string, password string) (*Archive, error)

func (*Archive) ExtractToFile

func (a *Archive) ExtractToFile(dstPath string, name string) error

ExtractToFile extracts a given file from the archive to a file on disk

func (*Archive) ExtractToWriter

func (a *Archive) ExtractToWriter(dst io.Writer, name string) error

ExtractToWriter writes the content of a given file inside the archive to dst

func (*Archive) GetFileReader

func (a *Archive) GetFileReader(name string) (io.ReadCloser, error)

GetFileReader returns a reader for reading a given file

func (*Archive) GetVolumes added in v1.2.0

func (a *Archive) GetVolumes() ([]string, bool)

type Entry

type Entry struct {
	Name       string
	Size       int64  // extracted size in bytes
	PackedSize int64  // -1 means "size unknown"
	Ratio      string // Ratio: 54%

	Modified time.Time

	Attributes  string // Attributes: -rw-r--r--
	CRC         string
	HostOS      string // zip, rar
	Compression string

	Flags string // Flags: encrypted (directory does not have this field)

	Type EntryType // Type: Directory or File

	RarFilename *string // the rar filename of the entry belongs to, a single entry may in two volumes
}

Entry describes a single file inside .rar,.zip archive

type EntryType

type EntryType string
const (
	EntryTypeFile      EntryType = "File"
	EntryTypeDirectory EntryType = "Directory"
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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