Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 (*Archive) HasDataType ¶ added in v0.6.17
func (*Archive) ReadFile ¶ added in v0.6.17
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) ReadAtMost ¶ added in v0.7.0
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 FileData ¶
type FileData struct {
ID FileID
Offsets [NumDataType]uint64
MainBufferOffset uint64
GPUBufferOffset uint64
Sizes [NumDataType]uint32
MainAlignment uint32
GPUAlignment uint32
Index uint32
}
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.
type Hash ¶
type Hash struct{ Value uint64 }
func ParseHash ¶ added in v0.5.20
ParseHash parses a big endian murmur64 hash. Ignores 0x prefix if present.
func (Hash) MarshalText ¶ added in v0.6.0
func (Hash) StringEndian ¶ added in v0.1.7
type HeaderData ¶
type Locus ¶ added in v0.6.17
Locus represents the location of a single partial game file (i.e. just main, stream or GPU) within an archive.
type ThinHash ¶
type ThinHash struct{ Value uint32 }
func ParseThinHash ¶ added in v0.7.0
ParseHash parses a big endian murmur32 hash. Ignores 0x prefix if present.