resfile

package
v0.0.0-...-e78e2ff Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2018 License: BSD-3-Clause Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(target io.WriteSeeker, source chunk.Provider) error

Write serializes the chunks from given provider 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 chunk.

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 FragmentedChunkWriter

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

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

func (*FragmentedChunkWriter) CreateBlock

func (writer *FragmentedChunkWriter) 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. Chunks 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) Chunk

func (reader *Reader) Chunk(id chunk.Identifier) (retrievedChunk *chunk.Chunk, err error)

Chunk returns a reader for the specified chunk. An error is returned if either the ID is not known, or the chunk could not be prepared.

func (*Reader) IDs

func (reader *Reader) IDs() []chunk.Identifier

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

type Writer

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

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

func NewWriter

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

NewWriter returns a new Writer instance prepared to add chunks. 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) CreateChunk

func (writer *Writer) CreateChunk(id chunk.Identifier, contentType chunk.ContentType,
	compressed bool) (*BlockWriter, error)

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

func (*Writer) CreateFragmentedChunk

func (writer *Writer) CreateFragmentedChunk(id chunk.Identifier, contentType chunk.ContentType,
	compressed bool) (*FragmentedChunkWriter, error)

CreateFragmentedChunk adds a new fragmented chunk to the current resource file. This chunk is closed by creating another chunk, 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

Jump to

Keyboard shortcuts

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