Files
bookhoard/internal/sevenzip/internal/bra/ppc.go
T
john-okeefe 46ae45ee92 feat: vendor bodgit/sevenzip package to remove go4.org dependency
Vendored the sevenzip package to eliminate dependency chain:
- sevenzip -> go4.org -> 25+ Google/Cloud/telemetry packages

Changes:
- Added internal/sevenzip/ with full package source
- Inlined go4.org/readerutil into multireaderat.go
- Updated all internal imports to use bookhoard/internal/sevenzip
- Preserved .cb7 comic archive support

This reduces bloat by ~4.9 MB and removes unused telemetry
dependencies while maintaining all functionality.
2026-02-22 16:29:21 -05:00

49 lines
777 B
Go

package bra
import (
"encoding/binary"
"io"
)
const ppcAlignment = 4
type ppc struct {
ip uint32
}
func (c *ppc) Size() int { return ppcAlignment }
func (c *ppc) Convert(b []byte, encoding bool) int {
if len(b) < c.Size() {
return 0
}
var i int
for i = 0; i < len(b) & ^(ppcAlignment-1); i += ppcAlignment {
v := binary.BigEndian.Uint32(b[i:])
if b[i+0]&0xfc == 0x48 && b[i+3]&3 == 1 {
if encoding {
v += c.ip
} else {
v -= c.ip
}
v &= 0x03ffffff
v |= 0x48000000
}
c.ip += uint32(ppcAlignment)
binary.BigEndian.PutUint32(b[i:], v)
}
return i
}
// NewPPCReader returns a new PPC io.ReadCloser.
func NewPPCReader(_ []byte, _ uint64, readers []io.ReadCloser) (io.ReadCloser, error) {
return newReader(readers, new(ppc))
}