pbo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PackingMethodUncompressed defines the file as uncompressed
	PackingMethodUncompressed PackingMethod = 0x00000000

	// PackingMethodPacked defines the file as "packed" (compressed)
	PackingMethodPacked = 0x43707273

	// PackingMethodProductEntry defines the entry as product entry
	// and is usually found at the very start of the pbo file.
	PackingMethodProductEntry = 0x56657273
)

Variables

View Source
var (
	// ErrInvalidProductEntry is returned when no valid product entry
	// could be found.
	ErrInvalidProductEntry = errors.New("invalid product entry")

	// ErrFileCorrupted is returned when the sha1 stored in the pbo doesn't matched
	// the calculated ones of this package.
	ErrFileCorrupted = errors.New("file seems corrupted")
)

Functions

func Pack

func Pack(dir, destination string, verbose bool) error

Pack packs dir into destination. The destination will be overwritten if it exists.

func Unpack

func Unpack(file, destination string, verbose bool) error

Unpack loads the PBO and unpacks it.

Types

type File

type File struct {
	Path    string            // Path contains the path to the current PBO file.
	Files   []*FileEntry      // Files contains all files within the PBO file.
	Headers map[string]string // Headers contains all header fields of the PBO file.
	// contains filtered or unexported fields
}

File contains methods to handle PBO files.

func Load

func Load(path string) (file *File, err error)

Load loads the PBO file.

func (*File) CacheEnabled

func (f *File) CacheEnabled() bool

CacheEnabled returns true if file caching is enabled.

func (*File) ClearCache

func (f *File) ClearCache()

ClearCache clears the file cache.

func (*File) Close

func (f *File) Close()

Close closes the file stream and clears the file cache. You can't read any files after this anymore!

func (*File) Load

func (f *File) Load() (err error)

Load (re)loads the PBO file.

func (*File) ToggleCache

func (f *File) ToggleCache(enable bool)

ToggleCache enables/disables the file caching mechanism according to enable.

func (*File) Unpack

func (f *File) Unpack(destination string, verbose bool) error

Unpack unpacks the PBO file.

type FileEntry

type FileEntry struct {
	Filename     string        // Filename contains the name of the file.
	Packing      PackingMethod // Packing contains the packing method.
	OriginalSize uint32        // OriginalSize contains the filesize before it has been packed.
	Reserved     uint32        // Reserved contains no useful information.
	Timestamp    time.Time     // Timestamp contains the last modification time.
	DataSize     uint32        // DataSize contains the actual size within the pbo.
	// contains filtered or unexported fields
}

FileEntry contains informations for a PBO file entry.

func NewEmptyEntry

func NewEmptyEntry() *FileEntry

NewEmptyEntry returns an empty *FileEntry which can be used as last file entry for pbos.

func NewProductEntry

func NewProductEntry() *FileEntry

NewProductEntry returns an empty *FileEntry with Packing set to PackingMethodProductEntry.

func (*FileEntry) Data

func (e *FileEntry) Data() ([]byte, error)

Data returns the current files data.

func (*FileEntry) IsEmpty

func (e *FileEntry) IsEmpty() bool

IsEmpty returns true if everything is set to 0/empty/default.

func (*FileEntry) IsProductEntry

func (e *FileEntry) IsProductEntry() bool

IsProductEntry returns true if Packing is equals PackingMethodProductEntry

type InvalidPackingMethod

type InvalidPackingMethod struct {
	Packing PackingMethod // Packing contains the unknown packing method.
}

InvalidPackingMethod is returned when the packing method is unknown.

func (*InvalidPackingMethod) Error

func (i *InvalidPackingMethod) Error() string

Error returns a user readable error string.

type PackingMethod

type PackingMethod uint32

PackingMethod describes the packing method used to store the file in the pbo.

Jump to

Keyboard shortcuts

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