Documentation
¶
Overview ¶
Package extract provides utilities for extracting zip files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidArchive = errors.New("invalid archive")
ErrInvalidArchive indicates the archive is invalid or contains unsafe entries.
Functions ¶
func GetZipRootDirectory ¶
GetZipRootDirectory returns the common root directory of all files in the ZIP. XenForo ZIPs typically have all files under an "upload/" directory.
func XenForoZip ¶
func XenForoZip(zipPath, destDir string, onProgress func(current, total int, filename string)) error
XenForoZip extracts a XenForo ZIP file to the destination. It extracts only files from within the "upload/" directory, stripping that prefix. This handles XenForo's ZIP structure where files are under upload/ but there may be other files like README at the root.
Types ¶
type Options ¶
type Options struct {
// StripComponents removes this many leading path components from extracted files.
// For example, if StripComponents=1 and the archive contains "upload/src/XF.php",
// it will be extracted as "src/XF.php".
StripComponents int
// OverwriteExisting allows overwriting existing files.
OverwriteExisting bool
// PreservePermissions preserves file permissions from the archive.
PreservePermissions bool
// OnProgress is called for each file extracted (if set).
OnProgress func(current, total int, filename string)
}
Options configures the extraction behavior.
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns the default extraction options.
Click to show internal directories.
Click to hide internal directories.