Documentation
¶
Index ¶
Constants ¶
const ( FormatTarGz = "tar.gz" FormatTarXz = "tar.xz" FormatTarZst = "tar.zst" FormatZip = "zip" FormatSHA256 = "sha256" FormatMD5 = "md5" )
The archive formats Tarbor can produce. Use these rather than string literals, so a typo is a compile error instead of a silent mismatch.
Variables ¶
This section is empty.
Functions ¶
func ResolveMIMEType ¶
ResolveMIMEType returns the MIME type to upload an archive of the given format with. Unknown formats get the generic application/octet-stream.
func Tar ¶
Tar creates an uncompressed tar archive of path, which can be a file or a directory, and returns the path of the archive.
A file is stored under its own name. For a directory, its contents are stored at the root of the archive, without the directory's own name, keeping the structure below it.
The archive is created in the temporary directory and should be removed by the caller when done with it.
Types ¶
type Archive ¶
type Archive struct {
// Path is where the archive file is on disk.
Path string
// Format is the archive format, one of or a concactenation the Format constants.
Format string
// Name is the archive's name without the format extension. The file is
// published as FileName().
Name string
}
Archive describes an archive file that has been built, or in dry-run mode would be built.
func Gzip ¶
Gzip compresses the file at path using gzip and returns an Archive for the result, a temporary file the caller should remove when done. Tar must be used before calling this function.
No file name or modification time is written to the gzip header, so the same input always produces byte-identical output.
func Xz ¶
Xz compresses the file at path using xz and returns an Archive for the result, a temporary file the caller should remove when done. Tar must be used before calling this function.
func Zip ¶
Zip creates a zip archive of path, which can be a file or a directory, and returns an Archive for the result, a temporary file the caller should remove when done. Tar is not needed first, since zip is an archive format of its own.
A file is stored under its own name. For a directory, its files are stored relative to it, without the directory's own name. Only files are stored, so empty directories are left out. Symlinks to files are followed and stored as regular files; symlinks to directories are not supported.
Entries keep their permission bits (so executables stay executable) but have no timestamps, which together with the sorted order of the directory walk makes the output the same every time for the same files.