sys

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sys uses programs installed to the host operating system to handle miscellaneous archives not usable with the Go packages.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDest       = errors.New("dest directory points to a file")
	ErrMagic      = errors.New("no unsupport for magic file type")
	ErrProg       = errors.New("archive program error")
	ErrReadr      = errors.New("system could not read the file archive")
	ErrTypeOut    = errors.New("magic file program result is empty")
	ErrSilent     = errors.New("archiver program silently failed, it return no output or errors")
	ErrWrongExt   = errors.New("filename has the wrong file extension")
	ErrUnknownExt = errors.New("the archive uses an unsupported file extension")
)

Functions

func ARJExtract added in v1.11.0

func ARJExtract(src, targets, dest string) error

ARJExtract extracts the targets from the src ARJ archive to the dest directory using the Linux arj program.

func ARJItem added in v1.11.0

func ARJItem(s string) bool

ArjItem returns true if the string is a row from an ARJ list.

func ARJReader added in v1.11.0

func ARJReader(src string) ([]string, string, error)

ARJReader returns the content of the src ARJ archive. There is an internal limit of 999 items.

func Extract

func Extract(filename, src, targets, dest string) error

Extract the targets from the src file archive to the dest directory using an Linux archive program. The program used is determined by the extension of the provided archive filename, which maybe different to src.

func LHAExtract added in v1.11.0

func LHAExtract(src, targets, dest string) error

LHAExtract extracts the targets from the src LHA/LZH archive to the dest directory using a Linux lha program. Either jlha-utils or lhasa work. Targets with spaces in their names are ignored by the program.

func LHAReader added in v1.11.0

func LHAReader(src string) ([]string, string, error)

LHAReader returns the content of the src LHA/LZH archive.

func MagicExt

func MagicExt(src string) (string, error)

MagicExt uses the Linux file program to determine the src archive file type. The returned string will be a file separator and extension. Note both bzip2 and gzip archives return a .tar extension prefix.

func MagicLHA

func MagicLHA(magic string) bool

MagicLHA returns true if the LHA file type is matched in the magic string.

func RarReader

func RarReader(src string) ([]string, string, error)

RarReader returns the content of the src RAR archive.

func Readr

func Readr(w io.Writer, src, filename string) ([]string, string, error)

Readr attempts to use programs on the host operating system to determine the src archive content and a usable filename based on its format.

func Rename

func Rename(ext, filename string) string

Rename the filename by replacing the file extension with the ext string. Leaving ext empty returns the filename without a file extension.

func ZipExtract

func ZipExtract(src, targets, dest string) error

ZipExtract extracts the target filenames from the src ZIP archive to the dest directory using the Linux unzip program. Multiple filenames can be separated by spaces.

func ZipReader

func ZipReader(w io.Writer, src string) ([]string, string, error)

ZipReader returns the content of the src ZIP archive.

Types

This section is empty.

Jump to

Keyboard shortcuts

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