Documentation
¶
Overview ¶
Package nvc implements a parser for nvc archive files.
The format of an archive is described below. All header values are stored on disk as little endian.
- NVC magic bytes (8 bytes)
- Number of entries in the archive's table of contents (32-bit little endian unsigned integer)
- Table of Contents entries (24 * n bytes, where n is the previously-specified number of entries)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoMagicFound error = errors.New("nvc magic bytes not found")
Functions ¶
This section is empty.
Types ¶
type Archive ¶
type Archive struct { Entries map[Hash]TocEntry // Map of hashes to table of contents entries EntryOrder []Hash // List of entry hashes in the order that they are stored in the archive // contains filtered or unexported fields }
type EntryFlags ¶
type EntryFlags uint32
EntryFlags describes how a file is stored on disk
const ( // EntryFlagNoCompression indicates that the file is stored in the NVC archive uncompressed EntryFlagNoCompression EntryFlags = 0 // EntryFlagZlibCompression indicates that the file is stored in the NVC archive with zlib compression EntryFlagZlibCompression EntryFlags = 1 // EntryFlagEncrypted indicates that the file is encrypted EntryFlagEncrypted EntryFlags = 3 )
type TocEntry ¶
type TocEntry struct { Hash Hash // 64-bit FNV-1a hash of the file's path on disk Offset uint32 // File's offset (in bytes) from the start of the nvc file RawLength uint32 // Length (in bytes) of the file after it has been extracted Length uint32 // Length (in bytes) of file as it is stored in the nvc file Flags EntryFlags // Indicates whether file is compressed or encrypted (TODO: determine if this is a bitmask) }
TocEntry is a file entry in the table of contents.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an nvc archive writer.
func NewWriter ¶
func NewWriter(w io.WriteSeeker, length uint32) (Writer, error)
NewWriter returns an nvc archive writer that writes to w. length is the number of files that will be placed in the archive. Finalize should be called once all files have been written to the archive (via Create or CreateCompressed).
func (*Writer) Create ¶
Create reads an archive member file from r and writes it to w.
Create increments w's internal Table of Contents entry counter by 1; it will panic if this counter exceeds the value of "length" that was passed to NewWriter. This function is not thread-safe; only one archive member file can be written to w at a time.
func (*Writer) CreateCompressed ¶
CreateCompressed increments w's internal Table of Contents entry counter by 1; it will panic if this counter exceeds the value of "length" that was passed to NewWriter. This function is not thread-safe; only one archive member file can be written to w at a time.