Documentation ¶
Index ¶
- Constants
- Variables
- func DetectRegion(patterns []string, keys []pyxtea.Key) (pyxtea.Key, error)
- func DetectRegions(patterns []string, keys []pyxtea.Key) ([]pyxtea.Key, error)
- func MustDetectRegion(patterns []string, keys []pyxtea.Key) pyxtea.Key
- type FS
- func (fs *FS) AddPak(reader *Reader) error
- func (fs *FS) AddPakFromFile(path string) error
- func (fs *FS) Directory(index int) string
- func (fs *FS) Extract(dest string) error
- func (fs *FS) ExtractFlat(dest string) error
- func (fs *FS) FileNameByIndex(index int) (string, error)
- func (fs *FS) LoadPaksFromFiles(paths []string) error
- func (fs *FS) LoadPaksFromGlob(pattern string) error
- func (fs *FS) Mount(mountpoint string) error
- func (fs *FS) NumDirectories() int
- func (fs *FS) NumFiles() int
- func (fs *FS) ReadFile(filename string) ([]byte, error)
- func (fs *FS) ReadFileByIndex(index int) (string, []byte, error)
- func (fs *FS) Root() (fusefs.Node, error)
- type FileEntryData
- type Reader
- type ReaderAtLen
- type TrailerData
Constants ¶
const ( // FileTypeBasic denotes an uncompressed file. FileTypeBasic = 0x00 // FileTypeLz denotes a file compressed with a custom LZ77 scheme. FileTypeLz = 0x01 // FileTypeDir denotes a directory entry. FileTypeDir = 0x02 // FileTypeLz2 denotes an LZ77 compressed file with obfuscation. FileTypeLz2 = 0x03 // FileTypeMask is a mask for grabbing the type of file for an entry. FileTypeMask = 0x0F // EntryTypeXOR is present on legacy XOR-padded entries. Filenames are // XOR'd with 0x71. If the EntryType is zero on-disk, it will be set to // XOR padded. EntryTypeXOR = 0x10 // EntryTypeXTEA is present on modern XTEA-encrypted entries. Filenames // and some metadata are encrypted with an XTEA cipher using 16 rounds. EntryTypeXTEA = 0x20 // EntryTypeBasic is an unencrypted entry type likely used for debugging. EntryTypeBasic = 0x80 // EntryTypeMask is a mask for grabbing the type of entry obfuscation. EntryTypeMask = 0xF0 )
Enumeration of values that can be combined to form a File Entry type.
const (
// FuseImplementation describes the fuse implementation in use in this build.
FuseImplementation = "bazilfuse"
)
const TrailerLen = 9
TrailerLen is the number of bytes the trailer takes up on-disk.
Variables ¶
var ( // ErrInvalidSignature is returned when the pak file contains an invalid // signature. ErrInvalidSignature = errors.New("invalid signature") // ErrStopIteration is returned if iteration ends early because the // callback returned false. ErrStopIteration = errors.New("iteration stopped") )
Errors returned by the reader.
var ( // ErrFuseUnsupported is returned by Mount when Fuse is not supported. ErrFuseUnsupported = errors.New("fuse mounting not supported in build") )
Functions ¶
func DetectRegion ¶
DetectRegion is like DetectRegions, but only returns one key, and fails if more than one or no keys pass validation. As a special case, if *all* regions validate, the first key is selected - this helps auto-detect succeed when dealing with pak files that contain no XTEA-ciphered entries.
func DetectRegions ¶
DetectRegions tries to decode the file table using each of the keys from the keys slice in order. Keys which have no errenous filenames are returned.
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS is an in-memory filesystem for pak files.
func (*FS) AddPakFromFile ¶
AddPakFromFile adds a new pak on the filesystem from a path.
func (*FS) ExtractFlat ¶ added in v0.0.2
ExtractFlat extracts the filesystem onto the host disk, into one flat folder.
func (*FS) FileNameByIndex ¶ added in v0.0.2
FileNameByIndex returns the path for a given file index.
func (*FS) LoadPaksFromFiles ¶
LoadPaksFromFiles loads pak files from a list of paths.
func (*FS) LoadPaksFromGlob ¶
LoadPaksFromGlob loads pak files using a glob pattern.
func (*FS) NumDirectories ¶
NumDirectories returns the number of directories in the filesystem.
func (*FS) ReadFileByIndex ¶
ReadFileByIndex returns the path and data for a given file index.
type FileEntryData ¶
type FileEntryData struct { PathLength byte Type byte Offset uint32 PackedFileSize uint32 RealFileSize uint32 }
FileEntryData is the data structure of each file entry in a Pak file.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads data from a pak file.
func NewReader ¶
func NewReader(k pyxtea.Key, r ReaderAtLen) (*Reader, error)
NewReader returns a new reader.
func (*Reader) CalcFileSize ¶
func (r *Reader) CalcFileSize(entry FileEntryData) (int64, error)
CalcFileSize calculates the actual filesize of a compressed file.
func (*Reader) ReadFile ¶
func (r *Reader) ReadFile(entry FileEntryData) ([]byte, error)
ReadFile reads an entire file.
func (*Reader) ReadFileTable ¶
func (r *Reader) ReadFileTable(callback func(path string, entry FileEntryData) bool) error
ReadFileTable reads the file table entirely. The iteration is stopped if callback returns false.
type ReaderAtLen ¶
ReaderAtLen is an io.ReaderAt that supports returning length.
type TrailerData ¶
TrailerData is the data structure at the end of a Pak file.