Table of Contents

Class GameFileLoader

Namespace
ValveResourceFormat.IO
Assembly
ValveResourceFormat.dll

Loads game files from VPK packages and disk with automatic path resolution.

public class GameFileLoader : IFileLoader, IDisposable

Inheritance

Implements

Inherited Members

Constructors

GameFileLoader(Package?, string?)

Initializes a new instance of the ValveResourceFormat.IO.GameFileLoader class.

public GameFileLoader(Package? currentPackage, string? currentFileName)

Parameters

currentPackage Package?

The current package to search for files in.

currentFileName string?

The path on disk to the current file that is being opened.

Remarks

fileName is needed when used by GUI when package has not yet been resolved.

Fields

CompiledFileSuffix

The suffix added to compiled file names.

public const string CompiledFileSuffix = "_c"

Field Value

string

Properties

CurrentPackage

Gets or sets the current package being processed.

public Package? CurrentPackage { get; set; }

Property Value

Package?

Methods

AddDiskPathToSearch(string)

Adds a disk path to the search paths.

public bool AddDiskPathToSearch(string searchPath)

Parameters

searchPath string

Returns

bool

AddPackageToSearch(string)

Loads and adds a VPK package to the search paths.

public Package AddPackageToSearch(string searchPath)

Parameters

searchPath string

Returns

Package

AddPackageToSearch(Package)

Adds an already loaded package to the search paths.

public void AddPackageToSearch(Package package)

Parameters

package Package

Dispose(bool)

Releases resources used by this instance.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

EnsureStringTokenGameKeys()

Ensures surface property string tokens are loaded and stored.

public void EnsureStringTokenGameKeys()

FindAndLoadSearchPaths(string?)

Finds and loads search paths from gameinfo.gi files.

protected void FindAndLoadSearchPaths(string? modIdentifierPath = null)

Parameters

modIdentifierPath string?

FindFile(string, bool)

Finds a file in packages or on disk.

public virtual (string? PathOnDisk, Package? Package, PackageEntry? PackageEntry) FindFile(string file, bool logNotFound = true)

Parameters

file string

The file path to find.

logNotFound bool

Whether to log if file is not found.

Returns

(string? PathOnDisk, Package? Package, PackageEntry? PackageEntry)

A tuple containing the path on disk, package, and package entry if found.

GetFileStream(string)

Gets a stream for reading a file.

public Stream? GetFileStream(string file)

Parameters

file string

Returns

Stream?

GetPackageEntryStream(Package, PackageEntry)

Gets a stream for reading a package entry.

public static Stream GetPackageEntryStream(Package package, PackageEntry entry)

Parameters

package Package
entry PackageEntry

Returns

Stream

Remarks

Do not use this method, it will be removed in the future in favor of a method in the ValvePak library.

LoadFile(string)

Loads a resource file.

public virtual Resource? LoadFile(string file)

Parameters

file string

Path to the file to load.

Returns

Resource?

Loaded resource, or null if not found.

LoadFileCompiled(string)

Same as ValveResourceFormat.IO.IFileLoader.LoadFile(System.String) but appends "_c" to the end of the string.

public virtual Resource? LoadFileCompiled(string file)

Parameters

file string

Path to the file to load (without _c suffix).

Returns

Resource?

Loaded compiled resource, or null if not found.

LoadShader(string)

Loads a shader collection by name.

public ShaderCollection LoadShader(string shaderName)

Parameters

shaderName string

Name of the shader to load.

Returns

ShaderCollection

Loaded shader collection, or null if not found.

LoadShaderFromDisk(string)

Loads a shader from disk by finding all its program files.

protected virtual ShaderCollection LoadShaderFromDisk(string shaderName)

Parameters

shaderName string

Returns

ShaderCollection

RemoveDiskPathFromSearch(string)

Removes a disk path from the search paths.

public bool RemoveDiskPathFromSearch(string searchPath)

Parameters

searchPath string

Returns

bool

RemovePackageFromSearch(Package)

Removes a package from the search paths.

public bool RemovePackageFromSearch(Package package)

Parameters

package Package

Returns

bool