pf

package module
v0.0.0-...-5fea475 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2018 License: MIT Imports: 10 Imported by: 0

README

pf is progress file.

LICENSE Build Status Go Report Card Godoc

Installation

go get -u github.com/0x5010/pf

Usage

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOutOfBounds bitmap out of bounds
	ErrOutOfBounds = errors.New("out of bounds")
)

Functions

This section is empty.

Types

type PF

type PF struct {
	Filepath   string
	Hash       string
	FileSize   int64
	PieceSize  int64
	PieceCount int
	Progress   *Progress
	// contains filtered or unexported fields
}

PF progress file

func New

func New(filename string, fileSize int64, opts ...PFOption) (*PF, error)

New initialization PF

func (*PF) Checked

func (pf *PF) Checked() bool

Checked check all done

func (*PF) WaitFinish

func (pf *PF) WaitFinish()

WaitFinish wait all done

func (*PF) Write

func (pf *PF) Write(index int, data []byte) error

Write write piece data to file

type PFOption

type PFOption func(*PF)

PFOption initialization option

func SetHash

func SetHash(hash string) PFOption

SetHash set PF Hash

func SetPieceCount

func SetPieceCount(pieceCount int) PFOption

SetPieceCount set PF PieceCount

func SetPieceSize

func SetPieceSize(pieceSize int64) PFOption

SetPieceSize set PF PieceSize

type Progress

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

Progress progress with bitmap

func LoadProgress

func LoadProgress(buf io.Reader) *Progress

LoadProgress load Progress from io.Reader

func NewProgress

func NewProgress(n int) *Progress

NewProgress new Progress

func (*Progress) Add

func (p *Progress) Add(x int)

Add finish x piece to progress

func (*Progress) Check

func (p *Progress) Check() bool

Check check progress finish

func (*Progress) Clear

func (p *Progress) Clear(x int)

Clear if runing piece fail, clear the runing piece in progress

func (*Progress) Contains

func (p *Progress) Contains(x int) (bool, error)

Contains check x finished

func (*Progress) FindFirstClear

func (p *Progress) FindFirstClear() int

FindFirstClear find first unfinshed piece in progress, mask x runing

func (*Progress) Remove

func (p *Progress) Remove(x int)

Remove unfinish x piece to progress

Jump to

Keyboard shortcuts

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