Documentation ¶
Overview ¶
Package kar is an api for an lz4 backed file format. It's purpose is to be well suited for resource streaming resources from it. It's designed to be memory mapped, so (unlike tar) it knows where all the files are located before they're read. This nescesitates a bit of an unusual setup, where the archive itself is not compressed in any form, rather every file is individually compressed, so it could be immediately read from it's place and decompressed on the fly. This somewhat compromises space efficiency, but space efficiency is not the primary goal of this package. It instead focuses on getting resources from disk to a usable state as fast as possible. It can be read from concurrently.
Index ¶
Constants ¶
const ( MagicLength = 4 HeaderSizeNumberLength = 16 )
Sizes relevant to the header of file
Variables ¶
var ( ErrFileFormat = errors.New("corrupted or not a kar archive") ErrTempFail = errors.New("temporary folder or file operation failed") ErrIOMisc = errors.New("some unknown error unhandled by the io occured") )
package errors
Functions ¶
This section is empty.
Types ¶
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
Archive provides concurrent io for a kar file, and can provide an io.Reader for each file separately to perform actions on.
func Open ¶
Open opens the kar archived from r. It will also check if the file is actually a kar archive, will return an error when file incorrect.
func (*Archive) GetFileInfo ¶
func (a *Archive) GetFileInfo(name string) (IndexEntry, error)
GetFileInfo queries for a file with a given name in the archive and returns it's info if found. If not found it will return os.ErrNotExist error.
type Builder ¶
Builder is the high level builder for the archive format. Arhives are versioned and cannot be appended to, This Builder is the way to create an archive. Whenever Add is called, KarBuilder will create a temporary dir, where it will store compressed files, then finally bundling them togeter and writing them out with WriteTo.
func NewBuilder ¶
NewBuilder creates a new Builder. Do not fill the Index in the header, it will be overwritten anyway.
type Header ¶
type Header struct { Author string DateCreated int64 Version int64 Index []IndexEntry }
Header is the file header for kar files.
func (*Header) MaxExpectedSize ¶
MaxExpectedSize calculates the amount of space a Header could take. It's important to know this before writing the header into the file. It only needs to be roughtly correct, offsets will be calculated with consideration for this number
type IndexEntry ¶
IndexEntry is info for one file in the file index.