v1

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: 4 Imported by: 0

Documentation

Overview

Package v1 provides functionality to read and parse SEGB version 1 files.

Index

Constants

View Source
const (
	// FileMagic is the expected magic number at the end of the header.
	FileMagic = "SEGB"
)

Variables

This section is empty.

Functions

func ReadSegb

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

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

Types

type Entry

type Entry struct {
	ID          int32      // Entry ID.
	Length      int32      // Length of the data section in bytes.
	State       EntryState // State of the entry.
	Timestamp1  float64    // First timestamp (Cocoa timestamp).
	Timestamp2  float64    // Second timestamp (Cocoa timestamp).
	CRCChecksum uint32     // CRC32 checksum of the data section.
	Unknown     int32      // Unknown field.
	Data        []byte     // Entry data.

	// Additional fields for convenience.
	Offset int64 // Offset of the entry in the file.
}

Entry represents an entry in a SEGB version 1 file.

func ReadEntry

func ReadEntry(stream io.ReadSeeker, idx int32) (*Entry, error)

ReadEntry reads an entry from the provided stream.

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 {
	EndOfDataOffset int32 // Offset where entry data ends.

	Magic [4]byte // File magic number, should be "SEGB".
	// contains filtered or unexported fields
}

Header represents the header of a SEGB version 1 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.

Jump to

Keyboard shortcuts

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