Documentation
¶
Overview ¶
Package explode is for use with the archive/zip package.
Explode was a decompression method authored in 1989 by Phil Katz and used in his MS-DOS compression tool, PKZip v0.91.
It is referred to as ZIP Implode/Explode method 6 and is based on the LZ77 algorithm.
This package was first prompted using Gemini in August 2026 and manually cleaned to be idiomatic and readable.
In 2020, Jason Summers authored a collection of public domain libraries named oldunzip. In-depth information on Implode was authored by Hans Wennborg in 2021, who programmed the public domain implode.c.
Example ¶
Example demonstrates the basic usage of the package.
package main
import (
"archive/zip"
"fmt"
"hash/crc32"
"io"
"path/filepath"
"github.com/Defacto2/archive/explode"
)
func main() {
const testdata = "testdata"
const testFile = "example-i.zip"
// Register the Explode decompressor with the archive zip package.
explode.Register()
name := filepath.Join(testdata, testFile)
rc, _ := zip.OpenReader(name)
defer rc.Close()
for n, f := range rc.File {
fr, _ := f.Open()
hasher := crc32.NewIEEE()
size := int64(f.UncompressedSize64) //nolint:gosec
_, _ = io.CopyN(hasher, fr, size)
fmt.Printf("%d. Decompressed method %d: %s, %dB\n"+
"Stored zip crc32 %x, and copied to buffer: %x\n",
n+1, f.Method, f.Name, f.UncompressedSize64, f.CRC32, hasher.Sum32())
fr.Close()
}
}
Output: 1. Decompressed method 6: I.BIN, 2048B Stored zip crc32 8314ddd9, and copied to buffer: 8314ddd9
Index ¶
Examples ¶
Constants ¶
View Source
const Explode uint16 = 6 // Method 6: Implode/Explode
Variables ¶
View Source
var ( ErrCorruptHeader = errors.New("explode: corrupt Shannon-Fano tree header") ErrCorruptStream = errors.New("explode: corrupt compressed stream") )
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.