dmio

package
v0.0.0-...-4655df8 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BufferSize = 1024 * 1024

BufferSize is the buffered reader size

Functions

func ActualLength

func ActualLength(action dmplugin.Action, fp statter) (int64, error)

ActualLength returns the length embedded in the action if it is not Inf (i.e. when it's an extent). Otherwise, interpret it as EOF and stat the actual file to determine the length on disk.

Types

type ActionReader

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

ActionReader wraps an io.SectionReader and also implements io.Closer by closing the embedded io.Closer.

func NewActionReader

func NewActionReader(action dmplugin.Action) (*ActionReader, int64, error)

NewActionReader returns an *ActionReader for the supplied action.

func (*ActionReader) Close

func (ar *ActionReader) Close() error

Close calls the embedded io.Closer's Close()

func (*ActionReader) Read

func (ar *ActionReader) Read(p []byte) (int, error)

Read calls the embedded *io.SectionReader's Read()

func (*ActionReader) Seek

func (ar *ActionReader) Seek(offset int64, whence int) (int64, error)

Seek calls the embedded *io.SectionReader's Seek()

type ActionWriter

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

ActionWriter wraps an io.WriterAt but imposes a base offset determined by the action's extent.

func NewActionWriter

func NewActionWriter(action dmplugin.Action) (*ActionWriter, error)

NewActionWriter returns an *ActionWriter for the supplied action.

func (*ActionWriter) Close

func (aw *ActionWriter) Close() error

Close calls the embedded io.Closer's Close()

func (*ActionWriter) Stat

func (aw *ActionWriter) Stat() (os.FileInfo, error)

Stat calls the embedded statter's Stat().

func (*ActionWriter) Write

func (aw *ActionWriter) Write(p []byte) (int, error)

Write calls the embedded io.Writer's Write().

func (*ActionWriter) WriteAt

func (aw *ActionWriter) WriteAt(p []byte, off int64) (int, error)

WriteAt calls the embedded io.WriterAt's WriteAt(), with the offset adjusted by the base offset.

type BufferedActionReader

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

BufferedActionReader wraps a buffered ActionReader and also implements io.Closer by closing the embedded io.Closer.

func NewBufferedActionReader

func NewBufferedActionReader(action dmplugin.Action) (*BufferedActionReader, int64, error)

NewBufferedActionReader returns a *BufferedActionReader for the supplied action.

func (*BufferedActionReader) Close

func (bar *BufferedActionReader) Close() error

Close calls the embedded io.Closer's Close()

func (*BufferedActionReader) Read

func (bar *BufferedActionReader) Read(p []byte) (int, error)

Read calls the embedded *bufio.Reader's Read()

type ProgressReader

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

ProgressReader wraps an io.ReaderAt and periodically invokes the supplied callback to provide progress updates.

func NewProgressReader

func NewProgressReader(src io.ReadSeeker, updateEvery time.Duration, f progressFunc) *ProgressReader

NewProgressReader returns a new *ProgressReader

func (*ProgressReader) Read

func (r *ProgressReader) Read(p []byte) (n int, err error)

Read calls internal Read and tracks how many bytes were read.

func (*ProgressReader) Seek

func (r *ProgressReader) Seek(offset int64, whence int) (int64, error)

Seek calls the wrapped Seeker's Seek

func (*ProgressReader) StopUpdates

func (p *ProgressReader) StopUpdates()

StopUpdates kills the updater goroutine

type ProgressWriter

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

ProgressWriter wraps an io.Writer and periodically invokes the supplied callback to provide progress updates.

func NewProgressWriter

func NewProgressWriter(dst io.Writer, updateEvery time.Duration, f progressFunc) *ProgressWriter

NewProgressWriter returns a new *ProgressWriter

func (*ProgressWriter) StopUpdates

func (p *ProgressWriter) StopUpdates()

StopUpdates kills the updater goroutine

func (*ProgressWriter) Write

func (w *ProgressWriter) Write(p []byte) (int, error)

Write writes len(p) bytes from p to the underlying data stream at offset off. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. WriteAt must return a non-nil error if it returns n < len(p).

type ProgressWriterAt

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

ProgressWriterAt wraps an io.WriterAt and periodically invokes the supplied callback to provide progress updates.

func NewProgressWriterAt

func NewProgressWriterAt(dst io.WriterAt, updateEvery time.Duration, f progressFunc) *ProgressWriterAt

NewProgressWriterAt returns a new *ProgressWriterAt

func (*ProgressWriterAt) StopUpdates

func (p *ProgressWriterAt) StopUpdates()

StopUpdates kills the updater goroutine

func (*ProgressWriterAt) WriteAt

func (w *ProgressWriterAt) WriteAt(p []byte, off int64) (int, error)

WriteAt writes len(p) bytes from p to the underlying data stream at offset off. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. WriteAt must return a non-nil error if it returns n < len(p).

Jump to

Keyboard shortcuts

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