Back to godoc.org
github.com/mholt/archiver

Package archiver

v1.1.2
Latest Go to latest

The latest major version is v3.

Published: Aug 29, 2016 | License: MIT | Module: github.com/mholt/archiver

Overview

Package archiver makes it super easy to create and open .zip, .tar.gz, and .tar.bz2 files.

Index

Variables

var CompressedFormats = map[string]struct{}{
	".7z":   {},
	".avi":  {},
	".bz2":  {},
	".cab":  {},
	".gif":  {},
	".gz":   {},
	".jar":  {},
	".jpeg": {},
	".jpg":  {},
	".lz":   {},
	".lzma": {},
	".mov":  {},
	".mp3":  {},
	".mp4":  {},
	".mpeg": {},
	".mpg":  {},
	".png":  {},
	".rar":  {},
	".tgz":  {},
	".xz":   {},
	".zip":  {},
	".zipx": {},
}

CompressedFormats is a (non-exhaustive) set of lowercased file extensions for formats that are typically already compressed. Compressing already-compressed files often results in a larger file, so when possible, we check this set to avoid that.

func Rar

func Rar(rarPath string, filePaths []string) error

Rar makes a .rar archive, but this is not implemented because RAR is a proprietary format. It is here only for symmetry with the other archive formats in this package.

func TarBz2

func TarBz2(tarbz2Path string, filePaths []string) error

TarBz2 creates a .tar.bz2 file at tarbz2Path containing the contents of files listed in filePaths. File paths can be those of regular files or directories. Regular files are stored at the 'root' of the archive, and directories are recursively added.

func TarGz

func TarGz(targzPath string, filePaths []string) error

TarGz creates a .tar.gz file at targzPath containing the contents of files listed in filePaths. File paths can be those of regular files or directories. Regular files are stored at the 'root' of the archive, and directories are recursively added.

func Unrar

func Unrar(source, destination string) error

Unrar extracts the RAR file at source and puts the contents into destination.

func UntarBz2

func UntarBz2(source, destination string) error

UntarBz2 untars source and decompresses the contents into destination.

func UntarGz

func UntarGz(source, destination string) error

UntarGz untars source and decompresses the contents into destination.

func Unzip

func Unzip(source, destination string) error

Unzip unzips the .zip file at source into destination.

func Zip

func Zip(zipPath string, filePaths []string) error

Zip creates a .zip file in the location zipPath containing the contents of files listed in filePaths. File paths can be those of regular files or directories. Regular files are stored at the 'root' of the archive, and directories are recursively added.

Files with an extension for formats that are already compressed will be stored only, not compressed.

type CompressFunc

type CompressFunc func(string, []string) error

CompressFunc is a function that makes an archive.

type DecompressFunc

type DecompressFunc func(string, string) error

DecompressFunc is a function that extracts an archive.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier