builder

package
v0.0.0-...-a300a6d Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateAndIncrementBlock

func AllocateAndIncrementBlock(block *uint32, size uint32) uint32

func NewPrimaryVolumeDescriptor

func NewPrimaryVolumeDescriptor(
	systemIdentifier, volumeIdentifier, volumeSetIdentifier, publisherIdentifier, dataPreparerIdentifier, applicationIdentifier string,
	volumeSpaceSize uint32,
	pathTableSize uint32,
	pathTableLLocationBlockNumber uint32,
	pathTableLOptionalLocationBlockNumber uint32,
	pathTableMLocationBlockNumber uint32,
	pathTableMOptionalLocationBlockNumber uint32,
	rootDirectory *Directory,
) (*spec.PrimaryVolumeDescriptor, error)

func RelocateTree

func RelocateTree(root *Directory, block *uint32)

Types

type BlockWriter

type BlockWriter struct {
	// contains filtered or unexported fields
}

func NewBlockWriter

func NewBlockWriter(wrapped io.Writer) *BlockWriter

func (*BlockWriter) BytesWritten

func (w *BlockWriter) BytesWritten() int64

func (*BlockWriter) WriteBlock

func (w *BlockWriter) WriteBlock(number uint32, contents io.WriterTo) error

func (*BlockWriter) WriteBlockFunc

func (w *BlockWriter) WriteBlockFunc(number uint32, writeTo func(io.Writer) (int64, error)) error

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

func NewEmptyDirectory

func NewEmptyDirectory(identifier spec.FileIdentifier, recordedAt time.Time, parent *Directory) *Directory

func (*Directory) Add

Add adds a file section as a direct descendant of a directory.

IMPORTANT: since file sections and identifiers themselves are not directly comparable, it is up to the caller to ensure entries are inserted in a spec-compliant sorting order. To ensure this, use spec.CompareDirectoryEntries before invoking Add.

func (*Directory) Entries

func (d *Directory) Entries() []spec.FileSection

func (*Directory) Location

func (d *Directory) Location() uint32

func (*Directory) Parent

func (d *Directory) Parent() *Directory

func (*Directory) ParentRecord

func (d *Directory) ParentRecord() spec.DirectoryRecord

func (*Directory) PointerRecord

func (d *Directory) PointerRecord() spec.DirectoryRecord

func (*Directory) Relocate

func (d *Directory) Relocate(newLocation uint32)

func (*Directory) SelfRecord

func (d *Directory) SelfRecord() spec.DirectoryRecord

func (*Directory) Walk

func (d *Directory) Walk(depthFirst bool) iter.Seq[RelocatableFileSection]

Walk returns all directory descendants, including itself, in either breadth-first or depth-first order. In breadth- first mode, Walk should obey the ordering constraints implied by spec.CompareDirectoryEntries.

func (*Directory) WriteTo

func (d *Directory) WriteTo(w io.Writer) (int64, error)

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(identifier spec.FileIdentifier, recordedAt time.Time, dataSize uint32, data func() (io.Reader, error)) *File

func (*File) Location

func (f *File) Location() uint32

func (*File) PointerRecord

func (f *File) PointerRecord() spec.DirectoryRecord

func (*File) Relocate

func (f *File) Relocate(newLocation uint32)

func (*File) WriteTo

func (f *File) WriteTo(w io.Writer) (int64, error)

type PathTable

type PathTable struct {
	// contains filtered or unexported fields
}

func NewPathTable

func NewPathTable(root *Directory) *PathTable

func (*PathTable) LPathTable

func (p *PathTable) LPathTable() spec.LPathTable

func (*PathTable) MPathTable

func (p *PathTable) MPathTable() spec.MPathTable

func (*PathTable) Records

func (p *PathTable) Records() iter.Seq[*spec.PathTableRecord]

func (*PathTable) Size

func (p *PathTable) Size() uint32

type RelocatableFileSection

type RelocatableFileSection interface {
	spec.FileSection

	Location() uint32
	Relocate(newLocation uint32)
	// contains filtered or unexported methods
}

RelocatableFileSection is an extension of spec.FileSection that allows for relocating the file section (which is generally the same thing as a file or directory).

This delegates locating files/directories on a disk to the caller, which allows for some separation of concerns and is generally neater than trying to tell a directory 'start on this block and allocate as you please'. In addition, it solves the problem of path table generation, since a path table size depends on the size of the directory tree, and should come before a directory on disk (this produces a chicken- and-egg problem).

Jump to

Keyboard shortcuts

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