filesystem

package
v0.0.0-...-d617ca5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvaildIndex = errors.New("invaild index")
	ErrWrongOrder   = errors.New("wrong order")
)

filesystem error

View Source
var (
	ErrPieceCheck = errors.New("check piece sha1 fail")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	Index int
	Begin int
	Data  []byte
}

Block is minimum unit for transport

type FileSystem

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

FileSystem manager data for memory and disk

func NewFileSystem

func NewFileSystem(torrent *meta.Torrent, path string) *FileSystem

NewFileSystem return a FileSystem instance

func (*FileSystem) Dump

func (fs *FileSystem) Dump() (int64, error)

Dump save data from memory to disk

func (*FileSystem) Need

func (fs *FileSystem) Need() *bitmap.Bitmap

Need return the need bitmap

func (*FileSystem) RequestData

func (fs *FileSystem) RequestData(index, begin, length int, blockc chan *Block)

RequestData get demand block from memory or disk

func (*FileSystem) SavePiece

func (fs *FileSystem) SavePiece(index, begin int, data []byte) (int, error)

SavePiece save a block to correspond piece

Jump to

Keyboard shortcuts

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