Documentation
¶
Index ¶
- Constants
- func NormalisePath(filePath string) string
- type FileNotFoundError
- type FileSystem
- func (fs *FileSystem) EnumerateResourcePaths() []string
- func (fs *FileSystem) GetFile(filename string) (io.Reader, error)
- func (fs *FileSystem) PakFile() *lumps.Pakfile
- func (fs *FileSystem) RegisterLocalDirectory(directory string)
- func (fs *FileSystem) RegisterPakFile(pakFile *lumps.Pakfile)
- func (fs *FileSystem) RegisterVpk(path string, vpkFile *vpk.VPK)
- func (fs *FileSystem) UnregisterLocalDirectory(directory string)
- func (fs *FileSystem) UnregisterPakFile()
- func (fs *FileSystem) UnregisterVpk(path string)
- type IFileSystem
- type Path
Constants ¶
const ( // ExtensionVmt Material file extension ExtensionVmt = ".vmt" // ExtensionVtf Texture file extension ExtensionVtf = ".vtf" )
File Extensions
const ( // BasePathMaterial is path prefix for all materials/textures BasePathMaterial = "materials/" // BasePathModels is path prefix for all models/props BasePathModels = "models/" )
FilePath prefixes
Variables ¶
This section is empty.
Functions ¶
func NormalisePath ¶
NormalisePath ensures that the same filepath format is used for paths, regardless of platform.
Types ¶
type FileNotFoundError ¶
type FileNotFoundError struct {
// contains filtered or unexported fields
}
FileNotFoundError
func NewFileNotFoundError ¶
func NewFileNotFoundError(filename string) *FileNotFoundError
NewFileNotFoundError
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem
func (*FileSystem) EnumerateResourcePaths ¶
func (fs *FileSystem) EnumerateResourcePaths() []string
EnumerateResourcePaths returns all registered resource paths. PakFile is excluded.
func (*FileSystem) GetFile ¶
func (fs *FileSystem) GetFile(filename string) (io.Reader, error)
GetFile attempts to get stream for filename. Search order is Pak->FileSystem->VPK
func (*FileSystem) PakFile ¶
func (fs *FileSystem) PakFile() *lumps.Pakfile
PakFile returns loaded pakfile There can only be 1 registered pakfile at once.
func (*FileSystem) RegisterLocalDirectory ¶
func (fs *FileSystem) RegisterLocalDirectory(directory string)
RegisterLocalDirectory register a filesystem path as a valid asset directory
func (*FileSystem) RegisterPakFile ¶
func (fs *FileSystem) RegisterPakFile(pakFile *lumps.Pakfile)
RegisterPakFile Set a pakfile to be used as an asset directory. This would normally be called during each map load
func (*FileSystem) RegisterVpk ¶
func (fs *FileSystem) RegisterVpk(path string, vpkFile *vpk.VPK)
RegisterVpk registers a vpk package as a valid asset directory
func (*FileSystem) UnregisterLocalDirectory ¶
func (fs *FileSystem) UnregisterLocalDirectory(directory string)
func (*FileSystem) UnregisterPakFile ¶
func (fs *FileSystem) UnregisterPakFile()
UnregisterPakFile removes the current pakfile from available search locations
func (*FileSystem) UnregisterVpk ¶
func (fs *FileSystem) UnregisterVpk(path string)
type IFileSystem ¶
type IFileSystem interface {
// PakFile returns a loaded map pakfile
PakFile() *lumps.Pakfile
// RegisterPakFile adds a maps pakfile.
RegisterPakFile(pakfile *lumps.Pakfile)
// RegisterVpk adds a VPK to this filesystem
RegisterVpk(path string, vpkFile *vpk.VPK)
// RegisterLocalDirectory adds a local directory
RegisterLocalDirectory(directory string)
// UnregisterLocalDirectory removes a registered local directory
UnregisterLocalDirectory(directory string)
// UnregisterPakFile removed a loaded pakfile
UnregisterPakFile()
// EnumerateResourcePaths returns all loaded paths (local, vpk locations). Does not include pakfile.
EnumerateResourcePaths() []string
// GetFile returns a file, or error if not found
GetFile(filename string) (io.Reader, error)
}
IFileSystem represents a Source Engine filesystem
func CreateFilesystemFromGameInfoDefinitions ¶
func CreateFilesystemFromGameInfoDefinitions(basePath string, gameInfo *keyvalues.KeyValue) IFileSystem
CreateFilesystemFromGameInfoDefinitions Reads game resource data paths from gameinfo.txt All games should ship with a gameinfo.txt, but it isn't actually mandatory.