arc

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 10 Imported by: 1

README

arc

arc is a pure Go library for creating, extracting, and managing archives. Based on mholt/archives and inspired by now-deprecated arc in archiver/v3.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArchivalMap = map[string]archives.Archival{
	"tar": archives.Tar{},
	"zip": archives.Zip{},
}
View Source
var CompressionMap = map[string]archives.Compression{
	"gz":  archives.Gz{},
	"bz2": archives.Bz2{},
	"xz":  archives.Xz{},
	"zst": archives.Zstd{},
	"lz4": archives.Lz4{},
	"br":  archives.Brotli{},
}

Maps to handle compression and archival types

View Source
var DEBUG = os.Getenv("ARC_DEBUG") == "true"

Functions

func Archive

func Archive(dir, outfile string, compression archives.Compression, archival archives.Archival) error

Archive is a function that archives the files in a directory dir: the directory to Archive outfile: the output file compression: the compression to use (gzip, bzip2, etc.) archival: the archival to use (tar, zip, etc.)

func ArchiveWithFilter added in v1.1.0

func ArchiveWithFilter(dir, outfile string, compression archives.Compression, archival archives.Archival, filter func(string) bool) error

ArchiveWithFilter is a function that archives the files in a directory while excluding certain files based on a filter dir: the directory to Archive outfile: the output file compression: the compression to use (gzip, bzip2, etc.) archival: the archival to use (tar, zip, etc.) filter: a function that returns true for files to be excluded

func Compress

func Compress(data []byte, compression archives.Compression) ([]byte, error)

Compress compresses input data using specified compressor.

func CompressBz2

func CompressBz2(data []byte) ([]byte, error)

CompressBz2 compresses input data using BZ2 compressor.

func CompressXz

func CompressXz(data []byte) ([]byte, error)

CompressXz compresses input data using XZ compressor.

func Decompress

func Decompress(data []byte, compression archives.Compression) ([]byte, error)

Decompress decompresses input compressed data.

func DecompressBz2

func DecompressBz2(data []byte) ([]byte, error)

DecompressBz2 decompresses input compressed data using BZ2 decompressor.

func DecompressXz

func DecompressXz(data []byte) ([]byte, error)

DecompressXz decompresses input compressed data using XZ decompressor.

func ExcludeFilesFilter added in v1.1.0

func ExcludeFilesFilter(excludePatterns []string) (func(string) bool, error)

ExcludeFilesFilter returns a filter function that excludes files matching the given regex patterns

func IncludeFilesFilter added in v1.1.0

func IncludeFilesFilter(includePatterns []string) (func(string) bool, error)

IncludeFilesFilter returns a filter function that includes only files matching the given regex patterns

func Unarchive

func Unarchive(tarball, dst string) error

Unarchive unarchives a tarball to a directory, symlinks and hardlinks are ignored.

Types

This section is empty.

Directories

Path Synopsis
cmd
arc command
compressor command

Jump to

Keyboard shortcuts

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