Documentation ¶
Overview ¶
package archive is heavily inspired by https://github.com/mholt/archiver/blob/master/tar.go (License MIT) just with an addition to archive directly to a given writer and removal of unused functionality
Index ¶
- Variables
- func Unarchive(source, destination string) error
- type File
- type FileInfo
- type ReadFakeCloser
- type Tar
- func (t *Tar) Archive(sources []string, destination string) error
- func (t *Tar) ArchiveToStream(output io.Writer, sources []string) error
- func (*Tar) CheckExt(filename string) error
- func (t *Tar) Close() error
- func (t *Tar) Create(out io.Writer) error
- func (t *Tar) Open(in io.Reader, size int64) error
- func (t *Tar) Read() (File, error)
- func (t *Tar) Unarchive(source, destination string) error
- func (t *Tar) Walk(archive string, walkFn WalkFunc) error
- func (t *Tar) Write(f File) error
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultTar = NewTar()
DefaultTar is a default instance that is conveniently ready to use.
var ErrFormatNotRecognized = fmt.Errorf("format not recognized")
ErrFormatNotRecognized is an error that will be returned if the file is not a valid archive format.
var ErrStopWalk = fmt.Errorf("walk stopped")
ErrStopWalk signals Walk to break without error.
Functions ¶
Types ¶
type File ¶
type File struct { os.FileInfo // The original header info; depends on // type of archive -- could be nil, too. Header interface{} // Allow the file contents to be read (and closed) io.ReadCloser }
File provides methods for accessing information about or contents of a file within an archive.
type ReadFakeCloser ¶
type Tar ¶
type Tar struct { // Whether to overwrite existing files; if false, // an error is returned if the file exists. OverwriteExisting bool // Whether to make all the directories necessary // to create a tar archive in the desired path. MkdirAll bool // A single top-level folder can be implicitly // created by the Archive or Unarchive methods // if the files to be added to the archive // or the files to be extracted from the archive // do not all have a common root. This roughly // mimics the behavior of archival tools integrated // into OS file browsers which create a subfolder // to avoid unexpectedly littering the destination // folder with potentially many files, causing a // problematic cleanup/organization situation. // This feature is available for both creation // and extraction of archives, but may be slightly // inefficient with lots and lots of files, // especially on extraction. ImplicitTopLevelFolder bool // If true, errors encountered during reading // or writing a single file will be logged and // the operation will continue on remaining files. ContinueOnError bool // contains filtered or unexported fields }
Tar provides facilities for operating TAR archives. See http://www.gnu.org/software/tar/manual/html_node/Standard.html.
func NewTar ¶
func NewTar() *Tar
NewTar returns a new, default instance ready to be customized and used.
func (*Tar) Archive ¶
Archive creates a tarball file at destination containing the files listed in sources. The destination must end with ".tar". File paths can be those of regular files or directories; directories will be recursively added.
func (*Tar) ArchiveToStream ¶
func (*Tar) Read ¶
Read reads the next file from t, which must have already been opened for reading. If there are no more files, the error is io.EOF. The File must be closed when finished reading from it.
func (*Tar) Unarchive ¶
Unarchive unpacks the .tar file at source to destination. Destination will be treated as a folder name.