stingray

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Returned when the file exists, but doesn't have the
	// requested data type.
	ErrFileDataTypeNotExist = errors.New("file data type doesn't exist")
	// Returned when the file doesn't exist.
	ErrFileNotExist = errors.New("file doesn't exist")
)

Functions

This section is empty.

Types

type Archive added in v0.6.17

type Archive struct {
	ID     Hash
	Paths  [NumDataType]string // stream and GPU are optional
	Header HeaderData
	Types  []TypeData
	Files  []FileData
}

func OpenArchive added in v0.6.17

func OpenArchive(mainPath string) (*Archive, error)

func (*Archive) HasDataType added in v0.6.17

func (ar *Archive) HasDataType(typ DataType) bool

func (*Archive) HasFile added in v0.6.17

func (ar *Archive) HasFile(fileIndex int, typ DataType) (bool, error)

func (*Archive) ReadFile added in v0.6.17

func (ar *Archive) ReadFile(fileIndex int, typ DataType, maxBytes int) ([]byte, error)

ReadFile attempts to read the file with the given index and type within the Archive. Returns a wrapped version of ErrFileDataTypeNotExist when the file exists, but doesn't have the requested data type. If maxBytes is zero, the entire file is read. If maxBytes is nonzero, maxBytes bytes or less are read.

type DataDir

type DataDir struct {
	// Base directory path
	Path string
	// Archive ID to files in that archive
	Archives map[Hash][]FileID
	// File ID to all file info (according to testing,
	// all file info structs in the slice should refer
	// to the same data).
	Files map[FileID][]FileInfo
}

DataDir represents the collection of game files.

func OpenDataDir

func OpenDataDir(ctx context.Context, dirPath string, onProgress func(curr, total int)) (_ *DataDir, err error)

Opens the "data" game directory, reading all file metadata. Ctx allows for granular cancellation (before each archive open). onProgress is optional.

func (*DataDir) Read added in v0.6.17

func (d *DataDir) Read(id FileID, typ DataType) ([]byte, error)

func (*DataDir) ReadAtMost added in v0.7.0

func (d *DataDir) ReadAtMost(id FileID, typ DataType, nBytes int) ([]byte, error)

Attempts to read at most nBytes from the given file, or all bytes if atMost is 0. Returns ErrFileNotExist if id doesn't exist and ErrFileDataTypeNotExist if the file exists, but doesn't have the requested data type.

type DataType

type DataType int
const (
	DataMain DataType = iota
	DataStream
	DataGPU
	NumDataType
)

func (DataType) ArchiveFileExtension added in v0.6.17

func (t DataType) ArchiveFileExtension() string

func (DataType) String

func (t DataType) String() string

type FileData

type FileData struct {
	ID               FileID
	Offsets          [NumDataType]uint64
	MainBufferOffset uint64
	GPUBufferOffset  uint64
	Sizes            [NumDataType]uint32
	MainAlignment    uint32
	GPUAlignment     uint32
	Index            uint32
}

type FileID

type FileID struct {
	Name Hash
	Type Hash
}

func NewFileID added in v0.6.17

func NewFileID(name Hash, typ Hash) FileID

func (FileID) Cmp added in v0.6.0

func (id FileID) Cmp(other FileID) int

Cmp compares two file IDs with order: name > type.

type FileInfo added in v0.6.17

type FileInfo struct {
	ArchiveID Hash
	Files     [NumDataType]Locus
}

FileInfo represent the component locations of a single game file.

func (FileInfo) Exists added in v0.6.17

func (f FileInfo) Exists(typ DataType) bool

type Hash

type Hash struct{ Value uint64 }

func ParseHash added in v0.5.20

func ParseHash(s string) (Hash, error)

ParseHash parses a big endian murmur64 hash. Ignores 0x prefix if present.

func Sum added in v0.6.17

func Sum[T ~[]byte | string](x T) Hash

Murmur64a hash

func (Hash) Cmp added in v0.6.0

func (h Hash) Cmp(other Hash) int

func (Hash) MarshalText added in v0.6.0

func (h Hash) MarshalText() ([]byte, error)

func (Hash) String

func (h Hash) String() string

func (Hash) StringEndian added in v0.1.7

func (h Hash) StringEndian(endian binary.ByteOrder) string

func (Hash) Thin added in v0.1.6

func (h Hash) Thin() ThinHash

64-bit hash to 32-bit hash

type HeaderData

type HeaderData struct {
	MagicNum [4]byte // 0x11 0x00 0x00 0xF0
	NumTypes uint32
	NumFiles uint32

	Unk00          [20]byte
	ApproxMainSize uint64 // aligned by 256 / weirdly offset
	ApproxGPUSize  uint64 // aligned by 256 / weirdly offset
	Unk01          [24]byte
}

type Locus added in v0.6.17

type Locus struct {
	Offset uint64
	Size   uint32
}

Locus represents the location of a single partial game file (i.e. just main, stream or GPU) within an archive.

func (Locus) Exists added in v0.6.17

func (l Locus) Exists() bool

Exists returns whether the referenced partial game file has any contents.

type ThinHash

type ThinHash struct{ Value uint32 }

func ParseThinHash added in v0.7.0

func ParseThinHash(s string) (ThinHash, error)

ParseHash parses a big endian murmur32 hash. Ignores 0x prefix if present.

func (ThinHash) Cmp added in v0.6.0

func (h ThinHash) Cmp(other ThinHash) int

func (ThinHash) MarshalText added in v0.6.0

func (h ThinHash) MarshalText() ([]byte, error)

func (ThinHash) String added in v0.1.6

func (h ThinHash) String() string

func (ThinHash) StringEndian added in v0.1.7

func (h ThinHash) StringEndian(endian binary.ByteOrder) string

type TypeData

type TypeData struct {
	Unk00         uint32
	Unk01         uint32
	Name          Hash
	Count         uint32
	Unk02         uint32
	MainAlignment uint32
	GPUAlignment  uint32
}

Jump to

Keyboard shortcuts

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