lzss

package
v0.0.0-...-e659864 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FalloutCompressStore uint32 = 0x10 // needs research, see fallout1-re/src/plib/db/db.c, de.flags 16
	FalloutCompressNone  uint32 = 0x20 // as-is, DAT1 sets SizePacked to 0
	FalloutCompressLZSS  uint32 = 0x40
)

Variables

View Source
var Default = LZSS{
	DictionarySize: 4096,
	MinMatch:       2,
	MaxMatch:       18,
}

Functions

This section is empty.

Types

type FalloutFile

type FalloutFile struct {
	// Stream containing compressed file data
	//
	// All `FalloutFile` functions keep `Stream` position unchanged,
	// as long there were no errors
	Stream io.ReadSeeker

	// File data offset;
	// same as in DAT1 file entry
	Offset int64

	// Size of compressed data in bytes
	//
	// DAT1 file entry sets it to 0 for uncompressed files;
	// in that case, uncompressed size should be used instead
	SizePacked int64

	// Compression mode
	//
	// Must be set to one of `FalloutCompress*` constants;
	// same as in DAT1 file entry
	CompressMode uint32
}

FalloutFile is a small wrapper around LZSS holding minimal required data about DAT1 file entry

func (FalloutFile) Decompress

func (file FalloutFile) Decompress() (bytes []byte, err error)

Decompress returns slice of bytes

Note that this function can handle uncompressed data

func (FalloutFile) ReadBlocks

func (file FalloutFile) ReadBlocks() (blocksBytes [][]byte, err error)

ReadBlocks returns compressed file split into block defined by DAT1

func (FalloutFile) ReadBlocksSize

func (file FalloutFile) ReadBlocksSize() (blocks []int64, err error)

ReadBlocksSize returns a slice containing compressed file blocks sizes

type LZSS

type LZSS struct {
	DictionarySize uint16
	MinMatch       byte
	MaxMatch       byte
}

func (LZSS) Decompress

func (lzss LZSS) Decompress(reader io.Reader, size int64) (output []byte, err error)

Decompress

Jump to

Keyboard shortcuts

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