encoder

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package encoder creates pxar archives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

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

Encoder writes pxar archives.

func NewEncoder

func NewEncoder(output, payloadOut io.Writer, metadata *pxar.Metadata, prelude []byte) *Encoder

NewEncoder creates a new pxar encoder writing to the given writers. If payloadOut is non-nil, the archive is split (v2 format). metadata describes the root directory. prelude is optional v2 prelude data.

func (*Encoder) AddDevice

func (e *Encoder) AddDevice(metadata *pxar.Metadata, name string, device format.Device) error

AddDevice adds a device node.

func (*Encoder) AddFIFO

func (e *Encoder) AddFIFO(metadata *pxar.Metadata, name string) error

AddFIFO adds a named pipe.

func (*Encoder) AddFile

func (e *Encoder) AddFile(metadata *pxar.Metadata, name string, content []byte) (LinkOffset, error)

AddFile adds a complete file to the archive.

func (e *Encoder) AddHardlink(name string, target string, targetOffset LinkOffset) error

AddHardlink adds a hard link.

func (*Encoder) AddSocket

func (e *Encoder) AddSocket(metadata *pxar.Metadata, name string) error

AddSocket adds a named socket.

func (e *Encoder) AddSymlink(metadata *pxar.Metadata, name string, target string) error

AddSymlink adds a symbolic link.

func (*Encoder) Close

func (e *Encoder) Close() error

Close finalizes the archive (writes root goodbye table and finishes).

func (*Encoder) CreateDirectory

func (e *Encoder) CreateDirectory(name string, metadata *pxar.Metadata) error

CreateDirectory pushes a new directory onto the stack.

func (*Encoder) CreateFile

func (e *Encoder) CreateFile(metadata *pxar.Metadata, name string, size uint64) (*FileWriter, error)

CreateFile returns a FileWriter for streaming file content.

func (*Encoder) Finish

func (e *Encoder) Finish() error

Finish finalizes the current directory (pops state, writes goodbye table).

type FileWriter

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

FileWriter writes file content to a pxar archive.

func (*FileWriter) Close

func (fw *FileWriter) Close() error

Close finalizes the file entry.

func (*FileWriter) FileOffset

func (fw *FileWriter) FileOffset() LinkOffset

FileOffset returns the file's offset for use with AddHardlink.

func (*FileWriter) Write

func (fw *FileWriter) Write(data []byte) (int, error)

Write writes data to the file.

func (*FileWriter) WriteAll

func (fw *FileWriter) WriteAll(data []byte) error

WriteAll writes all data to the file.

type LinkOffset

type LinkOffset uint64

LinkOffset represents a file offset usable with AddHardlink.

func (LinkOffset) Raw

func (o LinkOffset) Raw() uint64

Raw returns the raw byte offset.

Jump to

Keyboard shortcuts

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