pak

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Maximum number of files in PAK file.
	MaxFiles = 4096

	// Maximum length of file name in PAK file.
	MaxFileName = 56

	// Maximum size of PAK file and all files it contains.
	MaxOffset = 1<<31 - 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name    string
	Filepos uint32
	Filelen uint32
	// contains filtered or unexported fields
}

A File is a single file in a PAK archive. The file content can be accessed by calling Open.

func (*File) Open

func (f *File) Open() *io.SectionReader

Open returns a SectionReader that provides access to the File's contents. Multiple files may be read concurrently.

type ReadCloser

type ReadCloser struct {
	Reader
	// contains filtered or unexported fields
}

A ReadCloser is a Reader that must be closed when no longer needed.

func OpenReader

func OpenReader(name string) (*ReadCloser, error)

OpenReader will open the PAK file specified by name and return a ReadCloser.

func (*ReadCloser) Close

func (pak *ReadCloser) Close() error

Close closes the PAK file, rendering it unusable for I/O.

type Reader

type Reader struct {
	File []*File
	// contains filtered or unexported fields
}

A Reader serves content from a PAK archive.

func NewReader

func NewReader(r io.ReaderAt, size int64) (*Reader, error)

NewReader returns a new Reader reading from r, which is assumed to have the given size in bytes.

type Writer

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

Writer implements a PAK file writer.

func NewWriter

func NewWriter(w io.WriteSeeker) (*Writer, error)

NewWriter returns a new Writer writing a PAK file to w.

func OpenWriter

func OpenWriter(name string) (*Writer, error)

OpenWriter returns a new Writer writing a PAK file specified by name.

func (*Writer) Close

func (pak *Writer) Close() error

Close finishes writing the PAK file by writing the header and directory. If Writer was created by OpenWriter it also closes the underlying file.

func (*Writer) Create

func (pak *Writer) Create(name string) error

Create adds a file to the PAK file using the provided name. File contents must be written using Write before the next call to Create or Close.

func (*Writer) Write

func (pak *Writer) Write(p []byte) (int, error)

Writes content of the file created by the last call to Create. Can be called multiple times to write the data in chunks.

Jump to

Keyboard shortcuts

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