filesystem

package module
v0.0.0-...-23b6792 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2020 License: BSD-2-Clause Imports: 11 Imported by: 2

README

Forgery/core/filesystem

Improved filesystem from Galaco's (golang-source-engine)[https://github.com/golang-source-engine/filesystem]

Documentation

Index

Constants

View Source
const (
	// ExtensionVmt Material file extension
	ExtensionVmt = ".vmt"
	// ExtensionVtf Texture file extension
	ExtensionVtf = ".vtf"
)

File Extensions

View Source
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

func NormalisePath(filePath string) string

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
}

func NewFileNotFoundError

func NewFileNotFoundError(filename string) *FileNotFoundError

func (FileNotFoundError) Error

func (err FileNotFoundError) Error() string

type Filesystem

type Filesystem struct {
	// contains filtered or unexported fields
}

func CreateFromGameDir

func CreateFromGameDir(path string, gameInfo *keyvalues.KeyValue) *Filesystem

func CreateFromGameInfo

func CreateFromGameInfo(basePath string, gameInfo *keyvalues.KeyValue) *Filesystem

CreateFilesystemFromGameInfoDefinitions Reads game resource data paths from gameinfo.txt All games should ship with a gameinfo.txt, but it isn't actually mandatory.

func NewFilesystem

func NewFilesystem() *Filesystem

func (*Filesystem) AllPaths

func (fs *Filesystem) AllPaths() []string

AllPaths returns all the paths (files) that are currently loaded

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL