Documentation
¶
Overview ¶
Package vpk reads and writes Valve archives (VPK), the packages Source 2 games mount their resources from.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Files ¶
Files reads every file of a single-file Valve archive. A file without preload bytes aliases archive. An archive split across numbered parts is refused.
func Packed ¶
Packed returns tree with each directory named *.vpk shown as the archive Write packs from its files, the inverse of Unpacked. Its size comes from the files' sizes alone; opening it starts packing, and reading it streams the archive as Write produces it.
func Paths ¶
Paths reads only a Valve archive's directory, including split-archive indexes. Payloads are skipped; compatibility checks need resource names only.
func Size ¶
Size returns the length of the archive Write packs from tree, reading only the files' sizes.
func Unpacked ¶
Unpacked returns tree with each single-file archive named *.vpk shown as a directory of the same name holding the archive's files. Importing the result stores each file on its own, so a file a new version leaves unchanged stores as the same blocks. A file that is not a single-file archive, such as a split archive's directory, stays a file. Unpacked reads each archive whole the first time it is asked about and keeps its files for the returned tree's lifetime; an archive nested in another stays a file.
func Write ¶
Write packs every regular file in tree into one version 1 Valve archive on w, the layout the resource compiler writes: no preload bytes, and each file's data stored after the directory, in directory order. Files are ordered by extension, directory and name, so equal trees pack to equal bytes. Paths keep their case; the game reads lowercase resource names. Write reads each file twice, once for its checksum and once to copy it, and fails if a file changes in between.
Types ¶
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
Archive is an archive on disk, read one file at a time: a single-file archive such as an addon's, or a directory such as the game's pak01_dir.vpk whose files live in numbered parts beside it.
func OpenArchive ¶
OpenArchive reads the directory of the archive at path.