Documentation ¶
Overview ¶
Package lgres implements serialization of resources using the DOS format.
Index ¶
- Constants
- func Write(target io.WriteSeeker, source resource.Viewer) error
- type BlockWriter
- type CompoundResourceWriter
- type Reader
- type Writer
- func (writer *Writer) CreateCompoundResource(id resource.ID, contentType resource.ContentType, compressed bool) (*CompoundResourceWriter, error)
- func (writer *Writer) CreateResource(id resource.ID, contentType resource.ContentType, compressed bool) (*BlockWriter, error)
- func (writer *Writer) Finish() (err error)
Constants ¶
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" )
const ErrTargetNil ss1.StringError = "target is nil"
ErrTargetNil is returned if the target cannot be used.
const ErrWriterFinished ss1.StringError = "writer is finished"
ErrWriterFinished is returned if the writer was already finished.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockWriter ¶
type BlockWriter struct {
// contains filtered or unexported fields
}
BlockWriter is for writing data of a single block in a resource.
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 ¶
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.
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
compression
Package compression implements the LG resource file compression algorithm.
|
Package compression implements the LG resource file compression algorithm. |