Class PackageFileNames
Namespace: ValveResourceFormat.IO
Assembly: ValveResourceFormat.dll
File names of VPK packages: a package split into chunks is a name_dir.vpk directory file with numbered name_000.vpk archive chunks next to it, and a game folder mounts its numbered pakNN_dir.vpk packages.
public static class PackageFileNamesInheritance
object ← PackageFileNames
Methods
EnumeratePakDirectoryFiles(string)
Finds the pakNN_dir.vpk files a game mounts from a folder, in numeric order. Numbers may have gaps, and pak00_dir.vpk is never mounted.
public static IEnumerable<string> EnumeratePakDirectoryFiles(string folder)Parameters
folder string
Returns
IEnumerable<string>
FindAddonPackage(string, string)
Finds an addon packed as folder/name.vpk, or split into chunks with folder/name_dir.vpk.
public static string? FindAddonPackage(string folder, string name)Parameters
folder string
name string
Returns
string?
The path of the package, or null when there is none.
FitsIntoSingleFile(IEnumerable<(string EntryPath, long Length)>, Package?, bool)
Whether the file data of a package that is not split into chunk files still fits into it, at most MaxDirectoryFileDataSize, after adding files to it.
public static bool FitsIntoSingleFile(IEnumerable<(string EntryPath, long Length)> files, Package? package = null, bool replace = true)Parameters
files IEnumerable<(string EntryPath, long Length)>
Entry paths and lengths of the files to add.
package Package?
The package the files are added to, or null for a new package.
replace bool
Whether files replace the entries already at their path, or are skipped.
Returns
bool
GetDirectoryFile(string)
Gets the _dir.vpk directory file of a package, such as pak01_dir.vpk for pak01_003.vpk or pak01.vpk. The chunk suffix is only removed from an archive chunk, see PackageFileNames.IsArchiveChunk(string).
public static string GetDirectoryFile(string path)Parameters
path string
Returns
string
GetFilesToPack(string, string?, string)
Lists the files in a folder and its subfolders to pack, with their path relative to the folder. Files and folders that start with a dot, such as .git, are skipped.
public static List<(string PathOnDisk, string EntryPath)> GetFilesToPack(string folder, string? outputPackagePath, string entryPathPrefix = "")Parameters
folder string
The folder to pack.
outputPackagePath string?
Full path of the package being written, which is skipped along with its chunk files.
entryPathPrefix string
Prepended to each entry path.
Returns
List<(string PathOnDisk, string EntryPath)>
GetPackageFileNameError(string, bool)
Returns why a package can not be written to a path, or null when it can. The name must end in .vpk, must not be an archive chunk (see PackageFileNames.IsArchiveChunk(string)), and must end in _dir.vpk when the package is split into chunk files. A single file package may also be named _dir.vpk, which games need to mount it, such as a pakNN_dir.vpk addon.
public static string? GetPackageFileNameError(string path, bool splitIntoChunks)Parameters
path string
The path to write the package to.
splitIntoChunks bool
Whether the package is written split into chunk files.
Returns
string?
GetPackageName(string)
Gets the name of a package without the .vpk extension and the _dir or archive chunk suffix, such as pak01 for pak01_dir.vpk and pak01_003.vpk. A package read from a _dir.vpk file has this as its file name. The chunk suffix is only removed from an archive chunk, see PackageFileNames.IsArchiveChunk(string).
public static string GetPackageName(string path)Parameters
path string
Returns
string
GetPakNumber(string)
Gets the number of a pakNN_dir.vpk file name, or -1 for any other name.
public static int GetPakNumber(string fileName)Parameters
fileName string
Returns
int
IsArchiveChunk(string)
Whether a path is an archive chunk of a split package, such as pak01_003.vpk next to an existing pak01_dir.vpk. Without that directory file, a name such as surf_2024.vpk is a package of its own.
public static bool IsArchiveChunk(string path)Parameters
path string
Returns
bool
TryGetArchiveChunkDirectoryFile(string, out string?)
Gets the existing _dir.vpk directory file of an archive chunk, such as pak01_dir.vpk for pak01_003.vpk, see PackageFileNames.IsArchiveChunk(string).
public static bool TryGetArchiveChunkDirectoryFile(string path, out string? directoryFile)Parameters
path string
directoryFile string?
Returns
bool
False if the path is not an archive chunk.

