Documentation
¶
Overview ¶
Package zipx provides fast extraction of zip archives.
Index ¶
- Variables
- type Destination
- type DirInfo
- type FileInfo
- type Monitor
- type MonitorFunc
- type Progress
- type ReinterpretFunc
- type Reinterpreter
- type ZipX
- func (x *ZipX) Concurrency() int
- func (x *ZipX) Extract(ctx context.Context, r *zip.Reader, d Destination) error
- func (x *ZipX) ExtractFile(ctx context.Context, name string, d Destination) error
- func (x *ZipX) SetConcurrency(n int)
- func (x *ZipX) SetMonitor(m Monitor)
- func (x *ZipX) WithConcurrency(n int) *ZipX
- func (x *ZipX) WithMonitor(m Monitor) *ZipX
Constants ¶
This section is empty.
Variables ¶
var DefaultReinterpreter = ReinterpretFunc(noReinterpret)
DefaultReinterpreter is used by Dir (Destination)
var NullMonitor = MonitorFunc(func(_ Progress) {
})
NullMonitor is monitor which ignores progress entirely.
Functions ¶
This section is empty.
Types ¶
type Destination ¶
type Destination interface {
// CreateDir creates a new directory in destination.
CreateDir(name string, info DirInfo) error
// CreateFile creates a new file in destination.
//
// This can return io.WriteCloser as 1st return parameter, in that case
// zipx close it automatically after have finished to use.
CreateFile(name string, info FileInfo) (io.Writer, error)
}
Destination provides destination for extraction.
var Discard Destination = &discard{}
Discard is a destination which discard all extracted files and dirs.
type DirInfo ¶
type DirInfo struct {
// NonUTF8 indicates name would be non UTF-8 encoding.
NonUTF8 bool
// Mode represents directory's mode and permission bits.
Mode os.FileMode
}
DirInfo describes meta information of a dir.
type FileInfo ¶
type FileInfo struct {
// NonUTF8 indicates name would be non UTF-8 encoding.
NonUTF8 bool
// Size is estimated size to write.
Size uint64
// Modified is last updated time of file.
Modified time.Time
// Mode represents file's mode and permission bits.
Mode os.FileMode
}
FileInfo describes meta information of a file.
type Monitor ¶
type Monitor interface {
Monitor(Progress)
}
Monitor monitors progress of extraction.
type MonitorFunc ¶
type MonitorFunc func(Progress)
MonitorFunc is used to implement Monitor by function.
func (MonitorFunc) Monitor ¶
func (f MonitorFunc) Monitor(p Progress)
Monitor monitors progress of extraction.
type Progress ¶
type Progress struct {
// NumDone is number of extracted files.
NumDone int
// NumTotal is number of total files.
NumTotal int
}
Progress holds progress of extraction.
type ReinterpretFunc ¶
ReinterpretFunc is used to implement Reinterpreter with function.
func (ReinterpretFunc) Reinterpret ¶
func (f ReinterpretFunc) Reinterpret(s string) (string, error)
Reinterpret re-interprets string with another encoding.
type Reinterpreter ¶
Reinterpreter provides correction of encoding of names for files and dirs.
type ZipX ¶
type ZipX struct {
// contains filtered or unexported fields
}
ZipX is a zip archive extractor.
func (*ZipX) Concurrency ¶
Concurrency get current concurrency of extraction.
func (*ZipX) ExtractFile ¶
ExtractFile extracts all files from a zip archive file "name".
func (*ZipX) SetConcurrency ¶
SetConcurrency updates concurrency of extraction. 0 means no limitation.
func (*ZipX) SetMonitor ¶
SetMonitor updates a monitor of progress.
func (*ZipX) WithConcurrency ¶
WithConcurrency updates practical of extraction. 0 means no limitation.
func (*ZipX) WithMonitor ¶
WithMonitor updates a monitor of progress.