Documentation ¶
Index ¶
- Variables
- type Pack
- func (pack *Pack) Close() (err error)
- func (pack *Pack) Flush() error
- func (pack *Pack) ReadRecords() ([]*Record, error)
- func (pack *Pack) Records() []*Record
- func (pack *Pack) Revision() uint32
- func (pack *Pack) Search(path string) (*Record, bool)
- func (pack *Pack) Store(path string, info archive.Info, compressed bool, r io.Reader) (err error)
- func (pack *Pack) WriteTo(w io.Writer) (n int64, err error)
- type Record
- type RecordError
Constants ¶
This section is empty.
Variables ¶
var ( Signature = append([]byte("ndpk"), []byte{0x01, 0xff, 0x00}...) Terminator = []byte{0xff, 0x00, 0x00, 0xdd, 0x00} )
Functions ¶
This section is empty.
Types ¶
type Pack ¶
type Pack struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.8.0
Creates an empty *Pack with the provided *os.File.
The underlying contents of the file are NOT cleared unless *Pack.Flush has been called BEFORE a call to *Pack.ReadRecords. The contents of the *os.File are initialized with a signature ONLY if the length of the file is shorter than the signature.
func Open ¶
Creates a *Pack with the *os.File specified by path.
The existing contents of the *os.File are loaded into the *Pack. If there is an error when creating the *Pack of loading the *Pack's contents, the file is closed.
Calling *Pack.Close on a *Pack created through a call from Open causes the underlying file to be closed.
func (*Pack) Close ¶
Flushes the contents of the *Pack and then closes the underlying *os.File ONLY if the *Pack was created through a call to Open.
func (*Pack) Flush ¶ added in v0.8.0
Writes the *Pack's records and tailer data to the end of the underlying *os.File.
If the written data is less than the total size of the *os.File the file is truncated to the number of written bytes.
func (*Pack) ReadRecords ¶ added in v0.8.0
Reads the record data from the underlying *os.File and returns the resulting slice. The *Pack's internal records are updated with this result.
type Record ¶
type Record struct { Crc uint32 binarytree.Indices archive.Info IsCompressed bool // contains filtered or unexported fields }
func (*Record) DataPointer ¶ added in v0.8.0
func (*Record) Section ¶
Returns an io.Reader and md5 hash writer for the record's data. If the record is compressed, the underlying io.Reader is wrapped by a *segmented.DataReader.
The hash.Hash value contains the md5 chunksum for the uncompressed data, but only for the data read out of the io.Reader.
Example:
reader, hash, err := record.Section() if err != nil { return err } // The contents of the reader must be read before calling hash.Sum(nil) if err := io.Copy(file, reader); err != nil { return err } fmt.Println(hash.Sum(nil)) // the resulting checksum
func (*Record) TreeIndices ¶ added in v0.8.0
func (record *Record) TreeIndices() *binarytree.Indices
type RecordError ¶
func (*RecordError) Error ¶
func (err *RecordError) Error() string
func (*RecordError) Is ¶
func (err *RecordError) Is(target error) bool
func (*RecordError) Unwrap ¶
func (err *RecordError) Unwrap() error