Documentation ¶
Overview ¶
Pack a directory into a zip file with relative paths and one base directory. This can be used for quickly snapshoting a directory and should be compatible with standard zip tools.
Index ¶
Constants ¶
const ( PRINT_INFO = 1 PRINT_ERRORS = 2 PROGRESSBAR = 4 VERBOSE = 8 )
Flags to control the display and logging of events at the console.
const ( HUFFMAN_ONLY = -2 DEFAULT_COMPRESSION = -1 NO_COMPRESSION = 0 LEVEL1 = 1 LEVEL2 = 2 LEVEL3 = 3 LEVEL4 = 4 LEVEL5 = 5 LEVEL6 = 6 LEVEL7 = 7 LEVEL8 = 8 LEVEL9 = 9 FAIR_COMPRESSION = 2 GOOD_COMPRESSION = 5 BEST_COMPRESSION = 9 )
The compression levels that are available.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PackResult ¶
PackResult holds results of a packing operation. ScanErrNum represents the number of errors during file scanning, whereas ArchiveErrNum is the number of errors during archiving.
func Pack ¶
func Pack(source string, outfile string, targetBaseDir string, level CompressionLevel, flags int) (*PackResult, error)
Pack a directory, where symlinks are not followed. The source must be a directory path and outfile is a file path. The targetBaseDir is a directory prefix relative which the files are stored. If it is omitted, then it will be "snapshot", so all files will be in snapshot/file1, snapshot/file2, etc. The compression level needs to be one of the zip compression levels defined by constants, otherwise it is set to 2. The flags are used to set the log level, e.g. PRINT_ERRORS | PRINT_INFO will print errors and general info, but not a progress bar and won't list files.
The result of this function is a PackResult structure and an error. The error should be checked to see if the operation succeeded at all. The result structure contains information about individual file errors. It is possible for the error to be nil even though individual file errors occurred.