Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = errors.New("skip")
ErrSkip is a special error that can be returned from EntryProcessor to skip the extraction of an entry.
Functions ¶
Types ¶
type AbortErr ¶
type AbortErr struct {
Err error // Underlying error.
}
AbortErr is a special error that can be returned to abort the extraction of an entry. It's prominent use is during the validation of the file to signal critical errors unrelated to the validity of the file.
type DuplicateResolver ¶
DuplicateResolver is a function that is called when two files with the same name are found in the archive. The function is called with the name of the file, the first file and the second file. The function may return the file to use or an error.
type EntryProcessor ¶
EntryProcessor is a function that is called for each file in the archive before it is extracted, the arguments are as follows: name - name of the file in the archive, f - the file in the archive, dest - the destination (where the file is extracted). The function may process file in any desired way or return SkipErr to skip its extraction.
type ExtractorOptions ¶
type ExtractorOptions struct { EntryProcessor EntryProcessor // Function to process file before extraction. DuplicateResolver DuplicateResolver // Function to resolve duplicate files. FileValidator FileValidator // Function to validate existing or extracted files. }
type FileValidator ¶
FileValidator is a function that is called for each extracted entry together with destination and entry itself, it checks whether the extracted file is valid or not. If the file is invalid, it should return an error, otherwise nil is expected. This function is never called for directories.
type Option ¶
type Option func(*ExtractorOptions)
func WithDuplicateResolver ¶
func WithDuplicateResolver(f DuplicateResolver) Option
func WithEntryProcessor ¶
func WithEntryProcessor(f EntryProcessor) Option
func WithErrOnDuplicates ¶
func WithErrOnDuplicates() Option
WithErrOnDuplicates returns an option that sets the DuplicateResolveFunc to a function that returns an error when two files with the same name are found in the archive.
func WithFileValidator ¶
func WithFileValidator(f FileValidator) Option
WithFileValidator returns an option that sets the FileValidator to the given function.