StuffIt-Go

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: LGPL-2.1

README

StuffIt (SIT, StuffIt 5) package

Import the library from another Go module:

go get github.com/ObsoleteMadness/StuffIt-Go/stuffit@latest
import "github.com/ObsoleteMadness/StuffIt-Go/stuffit"

This package ports classic StuffIt archive parsing to Go for:

  • StuffIt 5.x (StuffIt (c)1997-... signature)
  • StuffIt 5.5 and earlier classic SIT! archives
  • MacBinary-wrapped .sit files
  • AppleSingle-wrapped .sit files (.as / .AS)
  • BinHex 4.0 (.hqx) wrappers that contain a StuffIt archive

StuffIt X (.sitx) is not supported.

Fork output hooks

The package never writes files itself. You implement data-fork and resource-fork handling independently.

Push (visitor): Extract() calls your ForkWriter:

  • WriteDataFork(entry, reader)
  • WriteResourceFork(entry, reader)

stuffit.Handler is a function-based adapter so you can set only the callbacks you need. A nil callback skips that fork.

Pull: iterate f.Archive.Entries and call f.OpenFork(entry.DataFork, opts) or f.OpenFork(entry.ResourceFork, opts) to stream each fork yourself.

The package does not enforce storage strategy. Consumers can map forks to:

  • AppleDouble sidecar files (for example ._filename)
  • Extended attributes
  • Any custom metadata stream format

Current compression support

  • Fully supported: None, RLE, Compress (LZW), Huffman, LZAH, Fixed Huffman, MW, LZ+Huffman (dynamic and preset table modes), Installer, Arsenic

Unsupported methods are returned as explicit errors during extraction.

Library usage

f, err := stuffit.Open("archive.sit")
if err != nil {
    return err
}
defer f.Close()

err = f.Extract(stuffit.Handler{
    DataFork: func(entry stuffit.Entry, r io.Reader) error {
        // persist the Macintosh data fork
        return nil
    },
    ResourceFork: func(entry stuffit.Entry, r io.Reader) error {
        // persist the Macintosh resource fork
        return nil
    },
    Directory: func(entry stuffit.Entry) error {
        return os.MkdirAll(entry.Path, 0o755)
    },
}, stuffit.ExtractOptions{})

The package never writes files itself. Implement ForkWriter (or use stuffit.Handler) to store forks however you want. To stream a single fork without a visitor, call f.OpenFork(entry.DataFork, opts) or f.OpenFork(entry.ResourceFork, opts).

CLI tool

Install from source:

go install github.com/ObsoleteMadness/StuffIt-Go/cmd/stuffit@latest

Or download a tagged release binary for macOS, Linux, or Windows (arm64 and amd64).

  • List entries:
    • stuffit list archive.sit
  • Extract full archive:
    • stuffit extract -C out archive.sit
  • Extract selected entries:
    • stuffit extract -C out archive.sit "Folder/File"

Resource forks are written as AppleDouble-style sidecars named ._<filename>.

Releases

GitHub Actions publishes CLI binaries only when a version tag is pushed, for example:

git tag v0.1.0
git push origin v0.1.0

Each tag creates a GitHub Release with:

  • stuffit-darwin-arm64, stuffit-darwin-amd64
  • stuffit-linux-arm64, stuffit-linux-amd64
  • stuffit-windows-arm64.exe, stuffit-windows-amd64.exe
  • SHA256SUMS

Credits

This library is inspired by XADMaster, MacPaw's Objective-C archive extraction library (the engine behind The Unarchiver). The classic StuffIt catalog layouts and compression methods implemented here follow that work.

The StuffIt 5 Arsenic (method 15) decoder follows Matthew T. Russotto's description of the format at http://www.russotto.net/arseniccomp.html.

Integration samples in testdata/stuffit-test-files come from Stephan Sokolow's stuffit-test-files collection of legally redistributable SIT archives. After clone, run git submodule update --init --recursive so the end-to-end tests can see them. Password-protected files in that set use password.

Directories

Path Synopsis
cmd
stuffit command
Package stuffit parses and extracts classic StuffIt archives.
Package stuffit parses and extracts classic StuffIt archives.

Jump to

Keyboard shortcuts

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