Versions in this module Expand all Collapse all v0 v0.1.6 Oct 27, 2026 Changes in this version + const DefaultCompressionLevel + const DefaultMaxEntries + const DefaultMaxEntryBytes + const DefaultMaxTotalBytes + var ErrPackageClosed = errors.New("ZIP 包已经关闭") + var ErrReadLimitExceeded = errors.New("读取内容超过大小限制") + func ApplyCompressionLevel(w *zip.Writer, level int) + func CheckSize(name string, size, maxEntryBytes, maxTotalBytes int64, remaining *int64) error + func EntryMethod(name string, mode CompressionMode) uint16 + func NormalizeCompressionLevel(level int) (int, error) + func ValidateEntryName(name string) error + func ValidateLimits(limits Limits) error + type CompressionMode string + const CompressionAuto + const CompressionDeflate + const CompressionStore + func NormalizeCompression(mode CompressionMode) (CompressionMode, error) + type Entry struct + CRC32 uint32 + CompressedSize uint64 + IsDir bool + Locked bool + Method uint16 + Mode fs.FileMode + Modified time.Time + Name string + Path string + SizeUnknown bool + UncompressedSize uint64 + Virtual bool + type LimitWriter struct + func NewLimitWriter(writer io.Writer, name string, entryRemaining, maxTotal int64, ...) *LimitWriter + func (l *LimitWriter) Write(p []byte) (int, error) + type Limits struct + MaxEntries int + MaxEntryBytes int64 + MaxTotalBytes int64 + type Package struct + func NewVirtual(entries []Entry, open func(string) (io.ReadCloser, error), closer io.Closer) (*Package, error) + func OpenBytes(data []byte) (*Package, error) + func OpenFile(filename string) (*Package, error) + func OpenReader(reader io.Reader) (*Package, error) + func OpenReaderAt(reader io.ReaderAt, size int64) (*Package, error) + func (p *Package) Close() error + func (p *Package) Entries() []Entry + func (p *Package) Has(fileName string) bool + func (p *Package) InputSize() int64 + func (p *Package) Lookup(fileName string) (Entry, bool) + func (p *Package) Open(fileName string) (io.ReadCloser, error) + func (p *Package) OpenEntry(entry Entry) (io.ReadCloser, error) + func (p *Package) Read(fileName string) ([]byte, error) + func (p *Package) ReadLimit(fileName string, limit int64) ([]byte, error) + func (p *Package) ReadXML(fileName string, target any) error + func (p *Package) ReadXMLLimit(fileName string, target any, limit int64) error + func (p *Package) WalkEntries(fn func(Entry) bool) error + type PackageSource interface + OFDPackage func() (*Package, error)