file_helper

package
v1.2.16-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_CHUNK_SIZE int64 = 512 * 1024
)

Variables

View Source
var (
	ErrInvalidArgument = errors.New("invalid argument")
	ErrHashNotMatch    = errors.New("hash not match")
	ErrBadChunkIndex   = errors.New("bad chunk index")
	ErrEmptyCacheFile  = errors.New("empty cache file")
)
View Source
var (
	DONE = errors.New("done")
)

Functions

This section is empty.

Types

type FileSyncer

type FileSyncer interface {
	Next(count int) (offsets []int64, err error)
	Sync(offset int64, data []byte, size int) (err error)
	Close() error
}

type FileSyncerOption

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

func NewFileSyncerOption

func NewFileSyncerOption() *FileSyncerOption

type RandomFileSyncer

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

func NewRandomFileSyncer

func NewRandomFileSyncer(opts ...SetFileSyncerOption) (*RandomFileSyncer, error)

func (*RandomFileSyncer) Close

func (fs *RandomFileSyncer) Close() (err error)

func (*RandomFileSyncer) Next

func (fs *RandomFileSyncer) Next(batch int) (offsets []int64, err error)

func (*RandomFileSyncer) Sync

func (fs *RandomFileSyncer) Sync(offset int64, data []byte, size int) (err error)

type SequenceFileSyncer

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

func NewSequenceFileSyncer

func NewSequenceFileSyncer(writeCloser io.WriteCloser, size int64, sha1_hash string, chunk_size int64) *SequenceFileSyncer

func (*SequenceFileSyncer) Close

func (sfs *SequenceFileSyncer) Close() error

func (*SequenceFileSyncer) Next

func (sfs *SequenceFileSyncer) Next(_ int) (offsets []int64, err error)

HACK: ignore count

func (*SequenceFileSyncer) Sync

func (sfs *SequenceFileSyncer) Sync(offset int64, data []byte, size int) (err error)

TODO: verify chunk hash

type SetFileSyncerOption

type SetFileSyncerOption func(*FileSyncerOption)

func SetCachePath

func SetCachePath(path string) SetFileSyncerOption

func SetChunkSize

func SetChunkSize(size int64) SetFileSyncerOption

func SetPath

func SetPath(path string) SetFileSyncerOption

func SetSha1Hash

func SetSha1Hash(hash string) SetFileSyncerOption

func SetSize

func SetSize(size int64) SetFileSyncerOption

Jump to

Keyboard shortcuts

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