arc

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: GPL-3.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package arc provides native decompression and reading for SEA ARC archives.

The core of this arc package was generated by Gemini Flash 3.8 in November 2026, and I have linted, refactored, and cleaned up both the code and comments to be human readable and idomatic Go.

As this is port of a number of public domain and open sourced libraries that were programmed and researched by many people. They have been listed in the included src.md markdown text.

Index

Constants

View Source
const (
	MethodOldStored byte = 1 // Old format uncompressed
	MethodStored    byte = 2 // Standard uncompressed
	MethodPacked    byte = 3 // Non-repeat RLE
	MethodSqueezed  byte = 4 // Huffman squeezing + RLE
	MethodCrunched5 byte = 5 // LZW old (uncrunched)
	MethodCrunched6 byte = 6 // LZW + RLE
	MethodCrunched7 byte = 7 // LZW + new hash + RLE
	MethodCrunched8 byte = 8 // Dynamic LZW + RLE
	MethodSquashed  byte = 9 // Squashed (13-bit dynamic LZW)
)

Variables

View Source
var (
	ErrCorruptLZW        = errors.New("corrupted crunched archive data")
	ErrCRCMismatch       = errors.New("crc-16 mismatch")
	ErrFormat            = errors.New("not a valid arc archive")
	ErrInvalidTree       = errors.New("file has an invalid decode tree")
	ErrUnsupportedMethod = errors.New("unsupported arc compression method")
)

Functions

func CRC16

func CRC16(data []byte) uint16

CRC16 calculates the CRC-16 checksum used by SEA ARC archives using the 0xA001 reversed polynomial.

func Uncrunch

func Uncrunch(r io.Reader, squash bool) ([]byte, error)

Uncrunch decompresses data compressed with the following SEA ARC methods:

  • Method 8: Dynamic Lempel-Zev packing with adaptive reset
  • Method 9: Squashing

There is one bool argument, squash.

  • To use method 8: squash=false
  • To use method 9: squash=true

func UncrunchLZW

func UncrunchLZW(r io.Reader, william, rle bool) ([]byte, error)

UncrunchLZW decompresses data compressed with the following SEA ARC methods:

  • Method 5: Lempel-Zev packing of repeated strings (old style)
  • Method 6: Lempel-Zev packing of repeated strings (new style)
  • Method 7: Lempel-Zev Williams packing with improved hash function

There are two bool arguments, william and rle.

  • To use method 5, william=false, rle=false
  • To use method 6, william=false, rle=true
  • To use method 7, william=true, rle=true

func UnpackRLE

func UnpackRLE(data []byte) []byte

UnpackRLE decompresses data compressed using SEA ARC Non-Repeat (NCR) / RLE90.

func Unsqueeze

func Unsqueeze(r io.Reader) ([]byte, error)

Unsqueeze decompresses data compressed with the following SEA ARC method:

  • Method 4: Compression of repeated characters plus Huffman SQueezing

Types

type File

type File struct {
	Header
	// contains filtered or unexported fields
}

File represents a file entry within an ARC archive.

func (*File) Open

func (f *File) Open() (io.ReadCloser, error)

Open returns a ReadCloser that provides access to the uncompressed file contents.

type Header struct {
	Name             string
	Method           byte
	CompressedSize   uint32
	UncompressedSize uint32
	Modified         time.Time
	CRC              uint16
}

Header represents a file header inside an ARC archive.

type Reader

type Reader struct {
	Files []*File
	// contains filtered or unexported fields
}

Reader provides read access to the entries of an ARC archive.

func NewReader

func NewReader(r io.ReaderAt, size int64) (*Reader, error)

NewReader returns a new Reader reading from r, which must have the given size.

func OpenReader

func OpenReader(name string) (*Reader, *os.File, error)

OpenReader opens the named ARC file and returns a Reader.

func (*Reader) ExtractAll

func (r *Reader) ExtractAll(dst string, targets ...string) error

ExtractAll extracts all files from the ARC archive to dst directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL