boar

package module
v0.0.0-...-418a6ee Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 20 Imported by: 39

README

boar

build Go Report Card GoDoc MIT licensed

boar will sniff any archive, and maybe even let you extract it.

Format Support

Format Extractor Native Dependency
.zip zipextractor (via savior) None (pure Go)
.tar tarextractor (via savior) None (pure Go)
.tar.gz tarextractor + gzipsource None (pure Go)
.tar.bz2 tarextractor + bzip2source None (pure Go)
.tar.xz tarextractor + xzsource Requires 7-zip libs
.rar rarextractor (via dmcunrar-go) dmc_unrar (C library)
.7z szextractor (via sevenzip-go) 7z.so + libc7zip.so
.exe (self-extracting) szextractor 7z.so + libc7zip.so

Formats with native dependencies will fail to extract if the required libraries are not available. The pure Go extractors work without any additional dependencies.

Native library installation

The szextractor package can automatically download the required 7-zip native libraries at runtime from broth.itch.zone/libc7zip, itch.io's binary distribution service. When szextractor.EnsureDeps is called, it checks for the required libraries next to the executable and fetches them from broth if they are missing or have mismatched hashes.

By default, library versions and hashes are pinned in the hardcoded formulas under szextractor/formulas/. You can override this to fetch from a specific broth channel (e.g. head for the latest build) using szextractor.SetDepChannel("head"), which skips hash verification and fetches from broth.itch.zone/libc7zip/{os}-{arch}-{channel}/LATEST/archive.zip. The szextractor.InstallDeps function can be used to force a fresh download regardless of what is already on disk.

Set the environment variable BUTLER_NO_DEPS=1 to disable automatic dependency fetching entirely.

Dependencies

License

boar's code itself is under MIT License, see LICENSE for details.

However:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnrecognizedArchiveType = errors.New("Unrecognized archive type")
)

Functions

func CleanFileName

func CleanFileName(fileName string) string

func SimpleExtract

func SimpleExtract(params *SimpleExtractParams) (*savior.ExtractorResult, error)

Types

type Contents

type Contents struct {
	Entries []*Entry
}

type EntriesLister

type EntriesLister interface {
	Entries() []*savior.Entry
}

type Entry

type Entry struct {
	Name             string
	UncompressedSize int64
}

Entry refers to a file entry in an archive

type ExtractParams

type ExtractParams struct {
	File       eos.File
	StagePath  string
	OutputPath string

	Consumer *state.Consumer

	Load LoadFunc
	Save SaveFunc
}

type Info

type Info struct {
	Strategy    Strategy
	Features    savior.ExtractorFeatures
	Format      string
	PostExtract []string
}

func Probe

func Probe(params ProbeParams) (*Info, error)

Probe attempts to determine the type of an archive Returns (nil, nil) if it is not a recognized archive type Returns (nil, non-nil) if it IS a recognized archive type, but something's wrong with it. Returns (non-nil, nil) if it is a recognized archive type and we are confident we can extract it correctly.

func (*Info) GetExtractor

func (ai *Info) GetExtractor(file eos.File, consumer *state.Consumer) (savior.Extractor, error)

func (*Info) String

func (ai *Info) String() string

type LoadFunc

type LoadFunc func(state any) error

type ProbeParams

type ProbeParams struct {
	File      eos.File
	Consumer  *state.Consumer
	Candidate *dash.Candidate
	OnEntries func(entries []*savior.Entry)
}

type SaveFunc

type SaveFunc func(state any) error

type SimpleExtractParams

type SimpleExtractParams struct {
	ArchivePath       string
	DestinationFolder string
	Consumer          *state.Consumer
}

type Strategy

type Strategy int
const (
	StrategyNone Strategy = 0

	StrategyZip Strategy = 100
	// linux binaries for example - they might be MojoSetup installers
	// (.zip files), or they might not be.
	StrategyZipUnsure Strategy = 101

	StrategyTar    Strategy = 200
	StrategyTarGz  Strategy = 201
	StrategyTarBz2 Strategy = 202
	StrategyTarXz  Strategy = 203

	StrategySevenZip Strategy = 300
	// .exe files for example - might be self-extracting
	// archives 7-zip can handle, or they might not.
	StrategySevenZipUnsure Strategy = 301

	// .dmg files can only be properly extracted on macOS.
	// 7-zip struggles with ISO9660 disk images for example,
	// and doesn't support APFS yet (as of 18.05)
	StrategyDmg Strategy = 400

	// .rar files we do *not* want to open while probing
	StrategyRar Strategy = 500
)

func (Strategy) String

func (as Strategy) String() string

type ThrottledSaveFunc

type ThrottledSaveFunc func(state any, force bool) bool

Saves the state if force is true or the interval has passed Returns true if the state was actually saved, false if not

func ThrottledSave

func ThrottledSave(params *ExtractParams) ThrottledSaveFunc

Directories

Path Synopsis
cmd
lilboar command
formulas
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.

Jump to

Keyboard shortcuts

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