fileManager

package
v0.0.0-...-b3da263 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2015 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CHUNK_SIZE = 4

Variables

This section is empty.

Functions

func Hash

func Hash(b []byte) string

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

func (a *BitVector) BitVectorOr(b BitVector)

BitVectorOr performs a | b and stores result in a

func (*BitVector) GetBit

func (b *BitVector) GetBit(pos uint) bool

GetBit

func (BitVector) PercentSet

func (b BitVector) PercentSet(n int) int

PercentSet returns fraction of bits set to 1 in the first n bits

func (*BitVector) SetBit

func (b *BitVector) SetBit(pos uint) bool

SetBit

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 (fc *FileController) CreateEmptyFile(name string, hash string, size int) (*MyFile, error)

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 Deserialize

func Deserialize(serial []byte) *MyFile

Deserialize

func NewMyFile

func NewMyFile() *MyFile

func (*MyFile) Close

func (f *MyFile) Close()

func (*MyFile) NumBlocks

func (f *MyFile) NumBlocks() int

NumBlocks returns the number of chunks created (based on a fixed size chunking scheme)

func (*MyFile) Open

func (f *MyFile) Open() error

Open opens file for writing

func (*MyFile) PercentComplete

func (f *MyFile) PercentComplete() int

PercentComplete returns the percentage of the file that is available

func (*MyFile) ReadChunk

func (f *MyFile) ReadChunk(chunkPos int) ([]byte, int, error)

func (*MyFile) Serialize

func (f *MyFile) Serialize() []byte

Serialize

func (*MyFile) String

func (f *MyFile) String() string

String returns a string representation

func (*MyFile) WriteChunk

func (f *MyFile) WriteChunk(chunkPos int, data []byte, size int) error

WriteChunk writes chunk. It assumes file exists and has a valid size

Jump to

Keyboard shortcuts

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