Documentation ¶
Overview ¶
Package tz enables you to transparently read or write TAR.GZ compressed archives and the files inside them.
Index ¶
- Variables
- func ExtractTo(srcPath, destPath string, entries ...string) (err error)
- func PackTo(srcPath, destPath string, includeDir ...bool) error
- func PackToFunc(srcPath, destPath string, fn func(fullName string, fi os.FileInfo) error, ...) error
- type File
- type ReadCloser
- type StreamArchive
- type TzArchive
- func (tz *TzArchive) AddDir(dirPath, absPath string) error
- func (tz *TzArchive) AddEmptyDir(dirPath string) bool
- func (tz *TzArchive) AddFile(fileName, absPath string) error
- func (z *TzArchive) Close() (err error)
- func (tz *TzArchive) DeleteIndex(idx int) error
- func (tz *TzArchive) DeleteName(name string) error
- func (tz *TzArchive) ExtractTo(destPath string, entries ...string) (err error)
- func (tz *TzArchive) ExtractToFunc(destPath string, fn cae.HookFunc, entries ...string) (err error)
- func (tz *TzArchive) Flush() (err error)
- func (tz *TzArchive) List(prefixes ...string) []string
- func (tz *TzArchive) Open(name string, flag int, perm os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
var Verbose = true
Switcher of printing trace information when pack and extract.
Functions ¶
Types ¶
type ReadCloser ¶
A ReadCloser represents a caller closable file reader.
func (*ReadCloser) Close ¶
func (rc *ReadCloser) Close() error
Close closes the tar.gz file, rendering it unusable for I/O.
type StreamArchive ¶
A StreamArchive represents a streamable archive.
func NewStreamArachive ¶
func NewStreamArachive(w io.Writer) *StreamArchive
NewStreamArachive returns a new streamable archive with given io.Writer. It's caller's responsibility to close io.Writer and streamer after operation.
func (*StreamArchive) Close ¶
func (s *StreamArchive) Close() (err error)
func (*StreamArchive) StreamFile ¶
StreamFile streams a file or directory entry into StreamArchive.
func (*StreamArchive) StreamReader ¶
StreamReader streams data from io.Reader to StreamArchive.
type TzArchive ¶
type TzArchive struct { *ReadCloser FileName string NumFiles int Flag int Permission os.FileMode // contains filtered or unexported fields }
A TzArchive represents a file archive, compressed with Tar and Gzip.
func Create ¶
Create creates the named tar.gz file, truncating it if it already exists. If successful, methods on the returned TzArchive can be used for I/O; the associated file descriptor has mode O_RDWR. If there is an error, it will be of type *PathError.
func New ¶
New accepts a variable that implemented interface io.Writer for write-only purpose operations.
func Open ¶
Open opens the named tar.gz file for reading. If successful, methods on the returned TzArchive can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.
func OpenFile ¶
OpenFile is the generalized open call; most users will use Open instead. It opens the named tar.gz file with specified flag (O_RDONLY etc.) if applicable. If successful, methods on the returned TzArchive can be used for I/O. If there is an error, it will be of type *PathError.
func (*TzArchive) AddEmptyDir ¶
AddEmptyDir adds a raw directory entry to TzArchive, it returns false if same directory enry already existed.
func (*TzArchive) DeleteIndex ¶
DeleteIndex deletes an entry in the archive by its index.
func (*TzArchive) DeleteName ¶
DeleteName deletes an entry in the archive by its name.
func (*TzArchive) ExtractTo ¶
ExtractTo extracts the whole archive or the given files to the specified destination. Call Flush() to apply changes before this.
func (*TzArchive) ExtractToFunc ¶
ExtractTo extracts the whole archive or the given files to the specified destination. It accepts a function as a middleware for custom operations.
func (*TzArchive) List ¶
List returns a string slice of files' name in TzArchive. Specify prefixes will be used as filters.