io

package
v0.9.271 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BYTE = 1.0 << (10 * iota)
	KIBIBYTE
	MEBIBYTE
	GIBIBYTE
)
View Source
const CHUNK_SIZE = 4 * MEBIBYTE

Variables

View Source
var SUPPORTED_COMPRESSIONS = map[string]bool{
	"":     true,
	"none": true,
	"tar":  true,
	"gzip": true,
	"gz":   true,
	"lz4":  true,
	"zlib": true,
}

Functions

func CompressionFromExt added in v0.9.238

func CompressionFromExt(path string) (string, error)

func CopyNotify added in v0.9.244

func CopyNotify(dst io.Writer, src io.Reader) chan error

CopyNotify asynchronously does io.Copy, notifying when done.

func DeleteIOSlave

func DeleteIOSlave(pid *uint32)

DeleteIOSlave deletes the slave associated with a PID. Uses the PID value of pointer at the time of the call.

func ExtForCompression added in v0.9.238

func ExtForCompression(compression string) (string, error)

func IsPipe added in v0.9.238

func IsPipe(fd uintptr) (bool, error)

func NewCompressionReader added in v0.9.238

func NewCompressionReader(reader io.Reader, compression string) (io.ReadCloser, error)

func NewCompressionWriter added in v0.9.238

func NewCompressionWriter(writer io.Writer, compression string) (io.WriteCloser, error)

func NewStreamIOMaster

func NewStreamIOMaster(
	slave grpc.BidiStreamingClient[daemon.AttachReq, daemon.AttachResp],
) (stdIn *StreamIOWriter, stdOut *StreamIOReader, stdErr *StreamIOReader, exitCode chan int, errors chan error)

func NewStreamIOSlave

func NewStreamIOSlave(
	ctx context.Context,
	wg *sync.WaitGroup,
	pid uint32,
	exitCode <-chan int,
) (stdIn *StreamIOReader, stdOut *StreamIOWriter, stdErr *StreamIOWriter)

func ReadFrom added in v0.9.244

func ReadFrom(src io.Reader, dst *os.File, compression string) (n int64, err error)

ReadFrom reads the contents of the src and writes it to the provided target. The function automatically detects the compression format from the file extension.

func SetIOSlave

func SetIOSlave(pid uint32, slave *StreamIOSlave)

SetIOSlave sets the slave associated with a PID.

func SetIOSlavePID

func SetIOSlavePID(oldId uint32, pid *uint32)

SetIOSlavePID updates the PID of an existing slave. Uses the PID value of pointer at the time of the call.

func Splice added in v0.9.238

func Splice(srcFd, dstFd uintptr) (int64, error)

Splice copies data from srcFd to dstFd using the splice system call, until EOF is reached. which moves data between two file descriptors without copying it b/w kernel and user space. One of the file descriptors must be a pipe. Check out splice(2) man page for more information.

func Tar added in v0.9.244

func Tar(src string, dst io.Writer, compression string) (err error)

Tar creates a tarball from the provided sources and writes it to the destination. FIXME: Works only with files, not directories in the tarball.

func Untar added in v0.9.244

func Untar(src io.Reader, dest string, compression string) (err error)

Untar decompresses the provided tarball to the destination directory. The destination directory should already exist. FIXME: Works only with files, not directories in the tarball.

func WriteTo added in v0.9.244

func WriteTo(src *os.File, dst io.Writer, compression string) (n int64, err error)

WriteTo writes the contents from the provided src to the the provided destination. Compression format is specified by the compression argument.

Types

type NopReadCloser added in v0.9.238

type NopReadCloser struct {
	io.Reader
}

func (NopReadCloser) Close added in v0.9.238

func (NopReadCloser) Close() error

type NopWriteCloser added in v0.9.238

type NopWriteCloser struct {
	io.Writer
}

func (NopWriteCloser) Close added in v0.9.238

func (NopWriteCloser) Close() error

type Storage added in v0.9.244

type Storage interface {
	Open(path string) (io.ReadCloser, error)
	Create(path string) (io.WriteCloser, error)
	Delete(path string) error

	IsDir(path string) (bool, error)
	ReadDir(path string) ([]string, error)

	IsRemote() bool
}

type StreamIOMaster

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

type StreamIOReader

type StreamIOReader struct {
	io.Reader
	io.WriterTo
	// contains filtered or unexported fields
}

func (*StreamIOReader) Read

func (s *StreamIOReader) Read(p []byte) (n int, err error)

func (*StreamIOReader) WriteTo

func (s *StreamIOReader) WriteTo(w io.Writer) (n int64, err error)

type StreamIOSlave

type StreamIOSlave struct {
	PID uint32
	// contains filtered or unexported fields
}

func GetIOSlave

func GetIOSlave(pid uint32) *StreamIOSlave

GetIOSlave returns the slave associated with a PID.

func (*StreamIOSlave) Attach

Attach attaches a master stream to the slave.

type StreamIOWriter

type StreamIOWriter struct {
	io.WriteCloser
	io.ReaderFrom
	// contains filtered or unexported fields
}

func (*StreamIOWriter) Close

func (s *StreamIOWriter) Close() error

func (*StreamIOWriter) ReadFrom

func (s *StreamIOWriter) ReadFrom(r io.Reader) (n int64, err error)

func (*StreamIOWriter) Write

func (s *StreamIOWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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