Documentation ¶
Overview ¶
Package archiver makes it super easy to create and open .zip, .tar.gz, and .tar.bz2 files.
Index ¶
- Variables
- func Rar(rarPath string, filePaths []string) error
- func TarBz2(tarbz2Path string, filePaths []string) error
- func TarGz(targzPath string, filePaths []string) error
- func Unrar(source, destination string) error
- func UntarBz2(source, destination string) error
- func UntarGz(source, destination string) error
- func Unzip(source, destination string) error
- func Zip(zipPath string, filePaths []string) error
- type CompressFunc
- type DecompressFunc
Constants ¶
This section is empty.
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.
Functions ¶
func Rar ¶
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 ¶
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 ¶
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 Zip ¶
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.
Types ¶
type CompressFunc ¶
CompressFunc is a function that makes an archive.
type DecompressFunc ¶
DecompressFunc is a function that extracts an archive.