fragment

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package fragment contains a Reader which can read Fragments which may be scattered around a volume (and perhaps even not in sequence). Typically these could be translated from MFT attribute DataRuns. To convert MFT attribute DataRuns to Fragments for use in the fragment Reader, use mft.DataRunsToFragments().

Implementation notes

When the fragment Reader is near the end of a fragment and a Read() call requests more data than what is left in the current fragment, the Reader will exhaust only the current fragment and return that data (which could be less than len(p)). A next Read() call will then seek to the next fragment and continue reading there. When the last fragment is exhausted by a Read(), it will return the remaining bytes read and a nil error. Any subsequent Read() calls after that will return 0, io.EOF.

When accessing a new fragment, the Reader will seek using the absolute Length in the fragment from the start of the contained io.ReadSeeker (using io.SeekStart).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fragment

type Fragment struct {
	Offset int64
	Length int64
}

Fragment contains an absolute Offset in bytes from the start of a volume and a Length of the fragment, also in bytes.

type Reader

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

A fragment Reader will read data from the fragments in order. When one fragment is depleted, it will seek to the position of the next fragment and continue reading from there, until all fragments have been exhausted. When the last fragment has been exhaused, each subsequent Read() will return io.EOF.

func NewReader

func NewReader(src io.ReadSeeker, fragments []Fragment) *Reader

NewReader initializes a new Reader from the io.ReaderSeeker and fragments and returns a pointer to. Note that fragments may not be sequential in order, so the io.ReadSeeker should support seeking backwards (or rather, from the start).

func (*Reader) Read

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

Jump to

Keyboard shortcuts

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