Documentation ¶
Index ¶
- Constants
- func Hash(b []byte) string
- type BitVector
- type FileController
- type MyFile
- func (f *MyFile) Close()
- func (f *MyFile) NumBlocks() int
- func (f *MyFile) Open() error
- func (f *MyFile) PercentComplete() int
- func (f *MyFile) ReadChunk(chunkPos int) ([]byte, int, error)
- func (f *MyFile) Serialize() []byte
- func (f *MyFile) String() string
- func (f *MyFile) WriteChunk(chunkPos int, data []byte, size int) error
Constants ¶
const CHUNK_SIZE = 4
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BitVector ¶
type BitVector struct {
BitVec uint64
}
Type BitVector provides an interface to a bit vector
func BitVectorOnes ¶
func BitVectorOnes() BitVector
BitVectorOnes returns bit vector with all bits set
func BitVectorZero ¶
func BitVectorZero() BitVector
BitVectorZero returns bit vector with all bits zero
func (*BitVector) BitVectorOr ¶
BitVectorOr performs a | b and stores result in a
func (BitVector) PercentSet ¶
PercentSet returns fraction of bits set to 1 in the first n bits
type FileController ¶
type FileController struct {
// contains filtered or unexported fields
}
Type FileController provides functions for interacting with the Public and Meta dirs
func NewFileController ¶
func NewFileController() *FileController
Init initializes the file controller and sets up the watcher
func (*FileController) CreateEmptyFile ¶
func (*FileController) DestroyFile ¶
func (fc *FileController) DestroyFile(name string) bool
DestroyFile destroys the file
func (*FileController) FileFromHash ¶
func (fc *FileController) FileFromHash(hash string) *MyFile
FileFromHash returns MyFile pointer from a full hash (TODO improve this)
func (*FileController) ListLocalFiles ¶
func (fc *FileController) ListLocalFiles() []MyFile
ListLocalFiles returns a list of MyFile pointers corresponding to files present in local Public dir
type MyFile ¶
type MyFile struct { Name string // file name FullHash string // hash of entire file HashBitVector BitVector // bit vector describing how many of these are present on the current machine Size int // size // contains filtered or unexported fields }
MyFile represents a file Name should be enough to uniquely identify the file locally. Full_hash should be enough to uniquely identify the file globally
func (*MyFile) NumBlocks ¶
NumBlocks returns the number of chunks created (based on a fixed size chunking scheme)
func (*MyFile) PercentComplete ¶
PercentComplete returns the percentage of the file that is available