v2

package
v0.0.0-...-f92e538 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package v2 provides functionality to read and parse SEGB v2 files.

Index

Constants

View Source
const (
	// FileMagic is the expected magic number at the beginning of the file.
	FileMagic = "SEGB"
	// TrailerRecordSize is the size in bytes of each trailer record.
	TrailerRecordSize = 16
)

Variables

This section is empty.

Functions

func PrettyHexdump

func PrettyHexdump(data []byte)

func ReadSegb

func ReadSegb(stream io.ReadSeeker) (*Header, []*Record, []*Entry, error)

ReadSegb reads and parses a SEGB version 2 file from the provided stream. It returns the header, a slice of records, a slice of entries, and an error if any.

Types

type Entry

type Entry struct {
	ID                uint32     // Entry identifier
	State             EntryState // State of the entry
	CreationTimestamp float64    // Creation timestamp (Cocoa timestamp)

	CRCChecksum uint32  // CRC32 checksum of the entry data
	Unknown     [4]byte // Unknown 4 bytes
	Data        []byte  // Entry data (NB: due to some kinks with alignment, this might contain extra zero bytes. Trim as needed)

	RawData []byte // Raw data including CRCChecksum and Unknown fields
}

Entry represents an entry in a SEGB file.

func (*Entry) VerifyCRC

func (e *Entry) VerifyCRC() bool

VerifyCRC calculates the CRC32 checksum of the entry data and compares it with the stored checksum.

type EntryState

type EntryState int32

EntryState represents the state of an entry.

const (
	EntryStateWritten EntryState = 0x01
	EntryStateDeleted EntryState = 0x03
	EntryStateUnknown EntryState = 0x04
)
type Header struct {
	Magic             [4]byte  // File magic number, should be "SEGB"
	EntryCount        int32    // Number of entries in the file
	CreationTimestamp float64  // Creation timestamp (Cocoa timestamp)
	UnknownPadding    [16]byte // Padding or reserved bytes, purpose unknown
}

Header represents the header of a SEGB file.

func ReadHeader

func ReadHeader(stream io.ReadSeeker) (*Header, error)

ReadHeader reads the header from the provided stream.

func (*Header) IsValidMagic

func (h *Header) IsValidMagic() bool

IsValidMagic checks if the magic number matches the expected value.

func (*Header) MagicString

func (h *Header) MagicString() string

MagicString returns the magic number as a string.

type Record

type Record struct {
	Offset            int32      // Offset of the entry data from the start of entries
	State             EntryState // State of the entry
	CreationTimestamp float64    // Creation timestamp (Cocoa timestamp)
}

Record represents a trailer record in a SEGB file.

func ReadRecord

func ReadRecord(stream io.ReadSeeker) (*Record, error)

ReadRecord reads a trailer record from the provided stream.

Jump to

Keyboard shortcuts

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