Documentation ¶
Overview ¶
Package archive provides support for reading the contents of archives such as .zip and .tar files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotArchive = errors.New("not a supported archive file")
ErrNotArchive is returned by Scan when passed a file it does not recognize as a readable archive.
Functions ¶
func Scan ¶
Scan sequentially scans the contents of an archive and invokes f for each file found. If f returns an error, scanning stops and that error is returned to the caller of Scan. The path is used to determine what type of archive is referred to by file. If the type is not known, it returns ErrNotArchive.
The supported archive formats are:
.zip -- ZIP archive (also .ZIP, .jar) .tar -- uncompressed tar .tar.gz -- gzip-compressed tar (also .tgz) .tar.bz2 -- bzip2-compressed tar
Scan only invokes f for file entries; directories are not included.
Types ¶
type ScanFunc ¶
A ScanFunc is invoked by the Scan function for each file found in the specified archive. The arguments are the filename as encoded in the archive, and either an error or a reader positioned at the beginning of the file's contents.
Any error returned by the ScanFunc is propagated to the caller of Scan, terminating the traversal of the archive. The callback may choose to ignore err, in which case the error is ignored and scanning continues.