Documentation
¶
Overview ¶
Package adc decodes Apple Data Compression (ADC), the byte-oriented LZ77 variant Apple uses for the "UDCO" flavour of UDIF disk images and, before that, for resources in classic Mac OS.
The format has no header, no checksum and no stored output length: a stream is a bare sequence of three opcodes, and it ends when its bytes run out. A caller that knows how long the output should be must check that itself.
out, err := adc.Decompress(src)
CGO is not used, so this builds for every target Go builds for.
The opcodes ¶
The first byte of each opcode says which one it is, and the format was read off streams written by Apple's own hdiutil rather than from any implementation of it:
1xxxxxxx literal run, (x+1) bytes follow, 1..128 01xxxxxx hhhhhhhh llllllll match, length (x+4) 4..67, offset (hl+1) 1..65536 00xxxxyy yyyyyyyy match, length (x+3) 3..18, offset (y+1) 1..1024
An offset counts backwards from the end of the output produced so far, so 1 is the byte just written. A match may be longer than its offset, in which case it repeats what it has already copied; that is the usual way a run of one byte is coded, and it is why the copy runs one byte at a time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrOffset = errors.New("adc: match offset reaches before the start of the output")
ErrOffset is returned when a match points further back than the output written so far, which no stream produced by a correct encoder ever does.
var ErrTruncated = errors.New("adc: truncated stream")
ErrTruncated is returned when an opcode's operands, or a literal run's bytes, reach past the end of the input.
Functions ¶
func Decompress ¶
Decompress returns the bytes the stream encodes. An empty input gives an empty output and no error: the format ends by exhaustion, so a stream of no opcodes is a stream of no bytes.
Types ¶
This section is empty.
