vpk

package module
v0.0.0-...-0671499 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MIT Imports: 15 Imported by: 0

README

vpk

Package vpk implements file operations on Valve Software's VPK format.

Documentation

Overview

Package vpk implements file operations on Valve Software's VPK format.

Index

Constants

This section is empty.

Variables

View Source
var ErrFileTooBig = errors.New("vpk: file too big")
View Source
var ErrInvalidMagic = errors.New("vpk: invalid magic number")

Functions

func Create

func Create(c Creator, contents []Entry, maxSize int64) (err error)

Types

type Creator

type Creator interface {
	// Main creates the main VPK file (*_dir.vpk or no suffix)
	Main() (io.WriteCloser, error)
	// Archive creates a data-only VPK file (*_###.vpk where # is a digit)
	Archive(index int16) (io.WriteCloser, error)
}

func MultiVPKCreator

func MultiVPKCreator(prefix string) Creator

MultiVPKCreator implements a Creator for a multi-part VPK on the OS filesystem. prefix should be the part before "_dir.vpk".

func SingleVPKCreator

func SingleVPKCreator(path string) Creator

SingleVPKCreator implements a Creator for a single-part VPK on the OS filesystem.

type Entry

type Entry interface {
	// The relative path to this file.
	Rel() string

	// Open the file for reading. Exactly one of the return values must be
	// non-nil. The contents of the io.ReadCloser should be the same each
	// time Open is called.
	Open() (io.ReadCloser, error)
}

type ErrCRCMismatch

type ErrCRCMismatch struct {
	Actual, Expected uint32
}

func (ErrCRCMismatch) Error

func (err ErrCRCMismatch) Error() string

type ErrInvalidEntry

type ErrInvalidEntry struct {
	Dir, Base, Ext string
}

func (ErrInvalidEntry) Error

func (err ErrInvalidEntry) Error() string

type ErrUnsupportedVersion

type ErrUnsupportedVersion uint32

func (ErrUnsupportedVersion) Error

func (err ErrUnsupportedVersion) Error() string

type File

type File interface {
	io.Reader
	io.Seeker
	io.Closer
	Stat() (os.FileInfo, error)
}

type Opener

type Opener interface {
	// Main opens the main VPK file (*_dir.vpk or no suffix)
	Main() (File, error)
	// Archive opens a data-only VPK file (*_###.vpk where # is a digit)
	Archive(index int16) (File, error)
}

func MultiVPK

func MultiVPK(prefix string) Opener

MultiVPK implements an Opener for a multi-part VPK on the OS filesystem. prefix should be the part before "_dir.vpk".

func SingleVPK

func SingleVPK(path string) Opener

SingleVPK implements an Opener for a single-part VPK on the OS filesystem.

type VPK

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

func Open

func Open(o Opener) (*VPK, error)

func (*VPK) Entry

func (v *VPK) Entry(rel string) Entry

Entry returns the file with the given relative path, or nil if no such file exists. The Close method of the io.ReadCloser returned by Entry.Open verifies the CRC of the file.

func (*VPK) Open

func (vpk *VPK) Open(rel string) (http.File, error)

func (*VPK) Paths

func (v *VPK) Paths() []string

Paths returns a slice containing the relative paths of all files in the VPK.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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