Documentation ¶
Overview ¶
Package tf2vpk manipulates Titanfall 2 VPKs.
Index ¶
- Constants
- func DescribeLoadFlags(flags uint32) (s []string)
- func DescribeTextureFlags(flags uint16) (s []string)
- func JoinName(prefix, name string, idx ValvePakIndex) (fn string)
- func NewCRC() hash.Hash32
- type Reader
- func (r *Reader) Close() error
- func (r *Reader) Open(name string) (fs.File, error)
- func (r *Reader) OpenBlockRaw(n ValvePakIndex) (io.ReaderAt, error)
- func (r *Reader) OpenChunkRaw(f ValvePakFile, c ValvePakChunk) (io.Reader, error)
- func (r *Reader) OpenFile(f ValvePakFile) (io.Reader, error)
- func (r *Reader) OpenFileParallel(f ValvePakFile, n int) (io.Reader, error)
- type ValvePak
- type ValvePakChunk
- type ValvePakDir
- type ValvePakFile
- func (f *ValvePakFile) CreateReader(r io.ReaderAt) (io.Reader, error)
- func (f *ValvePakFile) CreateReaderParallel(r io.ReaderAt, n int) (io.Reader, error)
- func (f *ValvePakFile) Deserialize(r io.Reader, path string) error
- func (f *ValvePakFile) LoadFlags() (uint32, error)
- func (f ValvePakFile) Serialize(w io.Writer) error
- func (f *ValvePakFile) TextureFlags() (uint16, error)
- type ValvePakIndex
Constants ¶
const ( ValvePakMagic uint32 = 0x55AA1234 ValvePakVersionMajor uint16 = 2 ValvePakVersionMinor uint16 = 3 ValvePakMaxChunkUncompressedSize uint64 = 0x100000 )
Titanfall 2 VPK constants.
const Ext = ".vpk"
Ext is the file extension of a VPK.
Variables ¶
This section is empty.
Functions ¶
func DescribeLoadFlags ¶ added in v0.0.2
DescribeLoadFlags returns a human-readable slice of strings describing the provided load flags.
func DescribeTextureFlags ¶ added in v0.0.2
DescribeTextureFlags returns a human-readable slice of strings describing the provided texture flags.
func JoinName ¶ added in v0.0.4
func JoinName(prefix, name string, idx ValvePakIndex) (fn string)
JoinName generates a filename for a VPK.
Types ¶
type Reader ¶
type Reader struct { Root ValvePakDir // contains filtered or unexported fields }
Reader reads Titanfall 2 VPKs.
func (*Reader) OpenBlockRaw ¶
func (r *Reader) OpenBlockRaw(n ValvePakIndex) (io.ReaderAt, error)
OpenBlockRaw opens a new reader reading the contents of a specific block.
func (*Reader) OpenChunkRaw ¶
func (r *Reader) OpenChunkRaw(f ValvePakFile, c ValvePakChunk) (io.Reader, error)
OpenChunkRaw returns a new reader reading the contents of a specific chunk.
func (*Reader) OpenFile ¶
func (r *Reader) OpenFile(f ValvePakFile) (io.Reader, error)
OpenFile returns a new reader reading the contents of a specific file. The checksum is verified at EOF.
func (*Reader) OpenFileParallel ¶ added in v0.0.2
OpenFileParallel is like OpenFile, but but decompresses chunks in parallel using n goroutines going no more than n compressed chunks ahead.
type ValvePak ¶ added in v0.0.4
type ValvePak interface { // Open opens a reader for the provided index. It may also implement // io.Closer (this should be checked by the caller). Open(ValvePakIndex) (io.ReaderAt, error) // Create opens a writer writing to the provided index, truncating it if it // exists. It may also implement io.Closer (this should be checked by the // caller). Create(ValvePakIndex) (io.Writer, error) // Delete deletes all files associated with the VPK. If no files exist, nil // is returned. Delete() error }
ValvePak provides access to VPK files.
func VPK ¶ added in v0.0.4
VPK returns a ValvePak reading the provided path/prefix/name. It may or may not exist.
func VPKFromPath ¶ added in v0.0.4
VPKFromPath attempts to return a ValvePak from the provided path. It may or may not exist.
type ValvePakChunk ¶
type ValvePakChunk struct { LoadFlags uint32 // note: these flags seem to be the same for all chunks in a ValvePakFile TextureFlags uint16 // ^, and these ones only seem to be on VTF files Offset uint64 CompressedSize uint64 UncompressedSize uint64 }
ValvePakChunk is a file chunk (possibly shared) in a Titanfall 2 VPK.
func (ValvePakChunk) CreateReader ¶
CreateReader creates a new reader for the chunk.
func (ValvePakChunk) CreateReaderRaw ¶
CreateReader creates a new reader for the raw data of the chunk.
func (*ValvePakChunk) Deserialize ¶
func (c *ValvePakChunk) Deserialize(r io.Reader) error
Deserialize parses a ValvePakChunk from r.
func (ValvePakChunk) IsCompressed ¶
func (c ValvePakChunk) IsCompressed() bool
IsCompressed checks if a chunk is compressed.
type ValvePakDir ¶
type ValvePakDir struct { Magic uint32 MajorVersion uint16 MinorVersion uint16 DataSize uint32 File []ValvePakFile // contains filtered or unexported fields }
ValvePakDir is the root directory of a Titanfall 2 VPK, providing byte-for-byte identical serialization/deserialization and validation (it will refuse to read or write invalid structs).
func (ValvePakDir) ChunkOffset ¶ added in v0.0.4
func (d ValvePakDir) ChunkOffset() (n uint32, err error)
ChunkOffset returns the starting offset of chunk data stored after the dir index (i.e., add this to the ValvePakChunk.Offset when reading a chunk for a file with ValvePakFile.Index == ValvePakIndexDir).
func (*ValvePakDir) Deserialize ¶
func (d *ValvePakDir) Deserialize(r io.Reader) error
Deserialize parses a ValvePakDir from r.
func (ValvePakDir) Serialize ¶
func (d ValvePakDir) Serialize(w io.Writer) error
Serialize writes an encoded ValvePakDir to w. The output should be identical byte-for-byte.
func (*ValvePakDir) SortFiles ¶
func (d *ValvePakDir) SortFiles() error
SortFiles sorts the files in an order suitable for the tree.
func (ValvePakDir) TreeSize ¶
func (d ValvePakDir) TreeSize() (uint32, error)
type ValvePakFile ¶
type ValvePakFile struct { Path string CRC32 uint32 PreloadBytes uint16 Index ValvePakIndex Chunk []ValvePakChunk }
ValvePakFile is a file in a Titanfall 2 VPK.
func (*ValvePakFile) CreateReader ¶
CreateReader creates a new reader for the file, checking the CRC32 at EOF.
func (*ValvePakFile) CreateReaderParallel ¶ added in v0.0.2
CreateReaderParallel is like CreateReader, but decompresses chunks in parallel using n goroutines going no more than n compressed chunks ahead.
func (*ValvePakFile) Deserialize ¶
func (f *ValvePakFile) Deserialize(r io.Reader, path string) error
Deserialize parses a ValvePakFile from r.
func (*ValvePakFile) LoadFlags ¶ added in v0.0.2
func (f *ValvePakFile) LoadFlags() (uint32, error)
LoadFlags gets the load flags for the file.
func (ValvePakFile) Serialize ¶
func (f ValvePakFile) Serialize(w io.Writer) error
Serialize writes an encoded ValvePakFile to w.
func (*ValvePakFile) TextureFlags ¶
func (f *ValvePakFile) TextureFlags() (uint16, error)
TextureFlags gets the texture flags for the file.
type ValvePakIndex ¶ added in v0.0.4
type ValvePakIndex uint16
ValvePakIndex is an VPK block index.
const ( ValvePakIndexDir ValvePakIndex = 0x7FFF // refers to data after the index in _dir.vpk ValvePakIndexEOF ValvePakIndex = 0xFFFF // not actually one )
func SplitName ¶ added in v0.0.4
func SplitName(fn, prefix string) (name string, idx ValvePakIndex, err error)
SplitName is the inverse of JoinName.
func (ValvePakIndex) GoString ¶ added in v0.0.4
func (i ValvePakIndex) GoString() string
func (ValvePakIndex) String ¶ added in v0.0.4
func (i ValvePakIndex) String() string
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
tf2-vpk2tar
Command tf2-vpk2tar streams Titanfall 2 VPKs as a tar archive.
|
Command tf2-vpk2tar streams Titanfall 2 VPKs as a tar archive. |
tf2-vpklist
Command tf2-vpklist shows information about a VPK.
|
Command tf2-vpklist shows information about a VPK. |
tf2-vpkoptim
Command tf2-vpkoptim repacks and filters Titanfall 2 VPKs.
|
Command tf2-vpkoptim repacks and filters Titanfall 2 VPKs. |
tf2-vpkunpack
Command tf2-vpkunpack unpacks or initializes a new vpk for modification and repacking.
|
Command tf2-vpkunpack unpacks or initializes a new vpk for modification and repacking. |
Package vpkutil provides useful helpers for manipulating VPK files.
|
Package vpkutil provides useful helpers for manipulating VPK files. |