lgres

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package lgres implements serialization of resources using the DOS format.

Index

Constants

View Source
const (
	// ErrSourceNil is returned if the source is not valid.
	ErrSourceNil ss1.StringError = "source is nil"

	// ErrFormatMismatch is returned if the format is unknown.
	ErrFormatMismatch ss1.StringError = "format mismatch"
)
View Source
const ErrTargetNil ss1.StringError = "target is nil"

ErrTargetNil is returned if the target cannot be used.

View Source
const ErrWriterFinished ss1.StringError = "writer is finished"

ErrWriterFinished is returned if the writer was already finished.

Variables

This section is empty.

Functions

func Write

func Write(target io.WriteSeeker, source resource.Viewer) error

Write serializes the resources from given source into the target. It is a convenience function for using Writer.

Types

type BlockWriter

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

BlockWriter is for writing data of a single block in a resource.

func (*BlockWriter) Write

func (writer *BlockWriter) Write(data []byte) (written int, err error)

Write stores the given data in the block and follows the Writer interface.

type CompoundResourceWriter

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

CompoundResourceWriter writes a resource with zero, one, or more blocks. Multiple blocks can be created and then written concurrently. Only when the resource is finished, the blocks are finalized.

func (*CompoundResourceWriter) CreateBlock

func (writer *CompoundResourceWriter) CreateBlock() *BlockWriter

CreateBlock provides a new, dedicated writer for a new block.

type Reader

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

Reader provides methods to extract resource data from a serialized form. Resources may be accessed out of sequence due to the nature of the underlying io.ReaderAt.

func ReaderFrom

func ReaderFrom(source io.ReaderAt) (reader *Reader, err error)

ReaderFrom accesses the provided source and creates a new Reader instance from it. Should the provided decoder not follow the resource file format, an error is returned.

func (*Reader) IDs

func (reader *Reader) IDs() []resource.ID

IDs returns the resource identifier available via this reader. The order in the slice is the same as in the underlying serialized form.

func (*Reader) View added in v1.4.0

func (reader *Reader) View(id resource.ID) (retrievedResource resource.View, err error)

View returns a reader prepared to extract data for the specified resource. An error is returned if either the ID is not known, or the resource could not be prepared.

type Writer

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

Writer provides methods to write a new resource file from scratch. Resources have to be created sequentially. The writer does not support concurrent creation and modification of resources.

func NewWriter

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

NewWriter returns a new Writer instance prepared to add resources. To finalize the created file, call Finish().

This function will write initial information to the target and will return an error if the writer did. In such a case, the returned writer instance will produce invalid results and the state of the target is undefined.

func (*Writer) CreateCompoundResource

func (writer *Writer) CreateCompoundResource(id resource.ID, contentType resource.ContentType,
	compressed bool) (*CompoundResourceWriter, error)

CreateCompoundResource adds a new compound resource to the current resource file. This resource is closed by creating another resource, or by finishing the writer.

func (*Writer) CreateResource

func (writer *Writer) CreateResource(id resource.ID, contentType resource.ContentType,
	compressed bool) (*BlockWriter, error)

CreateResource adds a new single-block resource to the current resource file. This resource is closed by creating another resource, or by finishing the writer.

func (*Writer) Finish

func (writer *Writer) Finish() (err error)

Finish finalizes the resource file. After calling this function, the writer becomes unusable.

Directories

Path Synopsis
internal
compression
Package compression implements the LG resource file compression algorithm.
Package compression implements the LG resource file compression algorithm.

Jump to

Keyboard shortcuts

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