disk

package
v0.0.0-...-699cd24 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrPayloadSizeTooLarge indicates the input payload size is too big
	ErrPayloadSizeTooLarge = errors.New("disk: bad payload size")
	// ErrBadCRC indicates there is not CRC can be found in the block
	ErrBadCRC = errors.New("disk: not a valid CRC")
)

Functions

This section is empty.

Types

type Block

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

Block is a buffer aligned with disk data block with two offset (left and right) representing the start and end of the effective payload inside the buffer

func (*Block) CRC

func (b *Block) CRC() uint32

CRC calculates the crc of the effective payload

func (*Block) Copy

func (b *Block) Copy(offset int, from []byte) int

Copy copies a byte array to the offset of the buffer It also updates the effective payload offsets

func (*Block) EndAt

func (b *Block) EndAt(offset int)

EndAt sets the block's right offset

func (*Block) IsEmpty

func (b *Block) IsEmpty() bool

IsEmpty tells if the buffer's effective payload is empty

func (*Block) IsPartial

func (b *Block) IsPartial() bool

IsPartial checks if effective payload is a partial payload

func (*Block) Merge

func (b *Block) Merge(toMerge *Block)

Merge uses current block as a base and merges another block on top of it

func (*Block) Payload

func (b *Block) Payload() []byte

Payload returns the effective payload as a byte array

func (*Block) Reset

func (b *Block) Reset()

Reset resets the effective payload to 0

func (*Block) StartFrom

func (b *Block) StartFrom(offset int)

StartFrom sets the block's left offset

type BlockReaderStream

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

func (*BlockReaderStream) NextBlock

func (brs *BlockReaderStream) NextBlock() (*Block, error)

type BlockWriterStream

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

func (*BlockWriterStream) NextBlock

func (bws *BlockWriterStream) NextBlock() (*Block, error)

NextBlock gets the next block from the input stream

type Disk

type Disk struct {
	// Name is the name of the disk.
	Name string
	// Root is the root path of the disk
	// Usually it is the mount point of a disk or a directory
	// under the mount point.
	Root string
}

TODO: interface?

func (*Disk) Mkdir

func (d *Disk) Mkdir(name string, all bool) error

func (*Disk) ReadAt

func (d *Disk) ReadAt(name string, p []byte, off int64) (int, error)

ReadAt reads up to len(p) bytes starting at byte offset off from the File into p. It returns the number of bytes read and an error, if any.

func (*Disk) ReadDir

func (d *Disk) ReadDir(name string) ([]os.FileInfo, error)

func (*Disk) Remove

func (d *Disk) Remove(name string, all bool) error

func (*Disk) Rename

func (d *Disk) Rename(oldname, newname string) error

func (*Disk) WriteAt

func (d *Disk) WriteAt(name string, p []byte, off int64) (int, error)

WriteAt writes len(p) bytes to the File starting at byte offset off. It returns the number of bytes written and an error, if any. WriteAt returns a non-nil error when n != len(p).

Jump to

Keyboard shortcuts

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