vpkutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package vpkutil provides useful helpers for manipulating VPK files.

Index

Constants

View Source
const VPKFlagsFilename = ".vpkflags"

VPKFlagsFilename is the name of the vpkflags file. It should be at the root of the folder to be packed.

View Source
const VPKIgnoreFilename = ".vpkignore"

VPKIgnoreFilename is the name of the vpkignore file. It should be at the root of the folder to be packed.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLIIncludeExclude added in v0.0.4

type CLIIncludeExclude struct {
	Exclude        *[]string
	ExcludeBSPLump *[]int
	Include        *[]string
}

CLIIncludeExclude filters VPK files using the provided globs.

func NewCLIIncludeExclude added in v0.0.4

func NewCLIIncludeExclude(set *pflag.FlagSet) CLIIncludeExclude

NewCLIIncludeExclude creates a new CLIIncludeExclude and registers it with the provided pflag.FlagSet.

func (CLIIncludeExclude) Skip added in v0.0.4

Skip determines whether to skip the specified file.

type CLIResolveOpen added in v0.0.4

type CLIResolveOpen struct {
	Arg       int
	Optional  bool
	VPKPrefix *string
	// contains filtered or unexported fields
}

CLIResolveOpen takes over the last 1 or 2 arguments, using them to resolve and open a VPK.

func NewCLIResolveOpen added in v0.0.4

func NewCLIResolveOpen(set *pflag.FlagSet, arg int, optional bool) CLIResolveOpen

NewCLIResolveOpen creates a new CLIResolveOpen and registers it with the provided pflag.FlagSet. It starts processing arguments at the provided index (where 0 is the first argument after flags have been parsed).

func (CLIResolveOpen) ArgCheck added in v0.0.4

func (ro CLIResolveOpen) ArgCheck() bool

ArgCheck ensures at 1-2 (or 0-2 if optional) arguments are provided at the specified argument index.

func (CLIResolveOpen) ArgHelp added in v0.0.4

func (ro CLIResolveOpen) ArgHelp() string

ArgHelp returns help text to add to the arguments usage.

func (CLIResolveOpen) Resolve added in v0.0.4

func (ro CLIResolveOpen) Resolve() (vpk tf2vpk.ValvePak, err error)

Resolve resolves the VPK path.

func (CLIResolveOpen) ResolveOpen added in v0.0.4

func (ro CLIResolveOpen) ResolveOpen() (vpk tf2vpk.ValvePak, r *tf2vpk.Reader, err error)

ResolveOpen resolves the VPK path and opens a reader.

type VPKFlags

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

VPKFlags is a list of rules for adding flags to files in a VPK. The rules are matched in reverse order, i.e., the last one takes effect.

func (*VPKFlags) Add

func (v *VPKFlags) Add(glob string, loadFlags uint32, textureFlags uint16) error

Add appends a new rule.

func (*VPKFlags) Generate

func (v *VPKFlags) Generate(root tf2vpk.ValvePakDir) error

Generate generates a new minimal VPKFlags (through inheriting from parent dirs) based on the provided VPK, replacing any existing rules.

func (*VPKFlags) GenerateExplicit

func (v *VPKFlags) GenerateExplicit(root tf2vpk.ValvePakDir) error

GenerateExplicit generates a new VPKFlags based on the provided VPK with all files explicitly set, replacing any existing rules.

func (VPKFlags) Match

func (v VPKFlags) Match(path string) (loadFlags uint32, textureFlags uint16)

Match returns the load and texture flags for the provided path.

func (*VPKFlags) Parse

func (v *VPKFlags) Parse(s string) error

Parse parses a vpkflags string, replacing any existing rules.

func (*VPKFlags) ParseFile

func (v *VPKFlags) ParseFile(name string) error

ParseFile is like Parse, but reads from a file.

func (VPKFlags) String

func (v VPKFlags) String() string

String returns a string which can later be parsed by Parse.

func (VPKFlags) Test

func (v VPKFlags) Test(root tf2vpk.ValvePakDir) error

Test ensures the rules match the existing flags in the provided VPK.

type VPKIgnore

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

VPKIgnore is a list of patterns to ignore when packing a VPK file in a similar fashion to gitignore.

Each pattern consists of a case-sensitive glob (same as with VPKFlags), optionally negated (denoted by a exclamation mark prefix in string form).

The rules are checked from top to bottom. If a rule is matched, the file is tentatively excluded unless matched by a negated rule afterwards (a matched negated rule before a match does nothing). If matched by a negated rule, the file is not excluded, and no further rules for that file are processed.

func (*VPKIgnore) Add

func (v *VPKIgnore) Add(glob string, negate bool) error

Add adds a rule.

func (*VPKIgnore) AddAutoExclusions

func (v *VPKIgnore) AddAutoExclusions(root tf2vpk.ValvePakDir) error

AddAutoExclusions automatically adds negated rules for files in a VPK.

func (*VPKIgnore) AddDefault

func (v *VPKIgnore) AddDefault()

AddDefault adds some general rules.

func (VPKIgnore) Match

func (v VPKIgnore) Match(path string) bool

Match checks whether the provided path should be ignored.

func (*VPKIgnore) Parse

func (v *VPKIgnore) Parse(s string) error

Parse parses a vpkignore string, replacing any existing rules.

func (*VPKIgnore) ParseFile

func (v *VPKIgnore) ParseFile(name string) error

ParseFile is like Parse, but reads from a file.

func (VPKIgnore) String

func (v VPKIgnore) String() string

String returns a string which can later be parsed by Parse.

Jump to

Keyboard shortcuts

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