format

package
v0.0.0-...-2b7ea9d Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: CC-BY-SA-4.0, MIT, MIT-0 Imports: 5 Imported by: 0

Documentation

Overview

The Format package describes the strucutres of the underlying Ponzu archive. This package contains primitives that are used mostly for the underlying

Index

Constants

View Source
const (
	PREAMBLE_STRING = "PONZU"
	PONZU_VERSION   = 1
)
View Source
const (
	HOST_OS_GENERIC string = "universe"
	HOST_OS_LINUX   string = "linux"
	HOST_OS_UNIX    string = "unix"
	HOST_OS_SELINUX string = "selinux"
	HOST_OS_NT      string = "winnt"
	HOST_OS_DARWIN  string = "darwin"
	HOST_OS_POSIX   string = "posix"
)
View Source
const BLOCK_SIZE uint64 = 4096

Variables

View Source
var (
	PREAMBLE_BYTES = []byte{'P', 'O', 'N', 'Z', 'U', 0}
)

Functions

This section is empty.

Types

type CompressionType

type CompressionType uint8
const (
	COMPRESSION_NONE   CompressionType = 0
	COMPRESSION_ZSTD   CompressionType = 1
	COMPRESSION_BROTLI CompressionType = 3
)

type Directory

type Directory struct{ File }

type File

type File struct {
	RecordBase
	Name     string    `cbor:"0, keyasint"`
	ModTime  time.Time `cbor:"1, keyasint"`
	Metadata any       `cbor:"2, keyasint"`
}
type Hardlink struct{ Link }
type Link struct {
	File
	Target string `cbor:"-1, keyasint"`
}

type OSSpecial

type OSSpecial struct {
	File
	SpecialType string `cbor:"-1, keyasint"`
	Mode        uint32 `cbor:"mknodMode"`
	Device      uint32 `cbor:"mknodDev"`
}

type PTimestamp

type PTimestamp uint64

type Preamble

type Preamble struct {
	// Magic value, must be PREAMBLE_STRING
	Magic [6]byte
	// Record type
	Rtype RecordType
	// Compression type of the body
	Compression CompressionType
	// Record flags
	Flags RecordFlags
	// Number of data-blocks that follow
	DataLen uint64
	// Number of bytes used in final data-block
	Modulo uint16
	// Checksum of data blocks
	DataChecksum [64]byte
	// Metadata Length
	MetadataLength uint16
	// checksum of the metadata
	MetadataChecksum [64]byte
}

func NewPreamble

func NewPreamble(
	rType RecordType,
	compression CompressionType,
	flags RecordFlags,
	length uint64,
	dataChecksum []byte,
	metadataLen uint16,
	metadataChecksum []byte) Preamble

func ReadPreamble

func ReadPreamble(r io.Reader) (*Preamble, error)

func (*Preamble) ToBytes

func (p *Preamble) ToBytes() []byte

func (*Preamble) WritePreamble

func (p *Preamble) WritePreamble(w io.Writer) error

type RecordBase

type RecordBase struct {
}

type RecordFlags

type RecordFlags uint16
const (
	RECORD_FLAG_NONE          RecordFlags = 0b00
	RECORD_FLAG_CONTROL_START RecordFlags = 0b1
	RECORD_FLAG_CONTROL_END   RecordFlags = 0b10
	RECORD_FLAG_CONTINUES     RecordFlags = 0b10
)

type RecordType

type RecordType uint8
const (
	RECORD_TYPE_CONTROL     RecordType = 0
	RECORD_TYPE_FILE        RecordType = 1
	RECORD_TYPE_HARDLINK    RecordType = 2
	RECORD_TYPE_SYMLINK     RecordType = 3
	RECORD_TYPE_DIRECTORY   RecordType = 4
	RECORD_TYPE_ZDICTIONARY RecordType = 5
	RECORD_TYPE_OS_SPECIAL  RecordType = 126
	RECORD_TYPE_CONTINUE    RecordType = 127
)

type StartOfArchive

type StartOfArchive struct {
	RecordBase
	// Version of the archive
	Version uint8 `cbor:"0,keyasint"`
	// Host OS the archive was made on
	Host string `cbor:"1,keyasint"`
	// Prefix to write all files to
	Prefix string `cbor:"2,keyasint"`
	// Comment for the archive (open text field)
	Comment string `cbor:"3,keyasint"`
}

All archives start with a Start of Archive header

type Symlink struct{ Link }

type ZstdDictionary

type ZstdDictionary struct{ RecordBase }

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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