tree

package
v0.0.0-...-4f831cf Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	Size    int64
	Content storage.ID
}

type ChunkedFile

type ChunkedFile struct {
	ElementHeader
	ContentSize int64
	Chunks      []Chunk
}

func NewChunkedFile

func NewChunkedFile(size int64) *ChunkedFile

func (*ChunkedFile) Add

func (c *ChunkedFile) Add(size int64, chunk storage.ID)

func (*ChunkedFile) Directory

func (c *ChunkedFile) Directory() *Directory

func (*ChunkedFile) File

func (c *ChunkedFile) File() File

func (*ChunkedFile) IsDir

func (c *ChunkedFile) IsDir() bool

func (*ChunkedFile) Reader

func (c *ChunkedFile) Reader() io.Reader

func (*ChunkedFile) Serialize

func (c *ChunkedFile) Serialize() ([]byte, error)

func (*ChunkedFile) Size

func (c *ChunkedFile) Size() int64

type Directory

type Directory struct {
	ElementHeader
	Entries []DirectoryEntry
}

func NewDirectory

func NewDirectory() *Directory

func (*Directory) Add

func (d *Directory) Add(name string, mode os.FileMode, modTime int64,
	entry storage.ID)

func (*Directory) Directory

func (d *Directory) Directory() *Directory

func (*Directory) File

func (d *Directory) File() File

func (*Directory) IsDir

func (d *Directory) IsDir() bool

func (*Directory) Serialize

func (d *Directory) Serialize() ([]byte, error)

type DirectoryEntry

type DirectoryEntry struct {
	Name    string
	Mode    os.FileMode
	ModTime int64
	Entry   storage.ID
}

type Element

type Element interface {
	SetStorage(st storage.Accessor)
	Serialize() ([]byte, error)
	IsDir() bool
	Directory() *Directory
	File() File
}

func Deserialize

func Deserialize(data []byte, st storage.Accessor) (Element, error)

func DeserializeID

func DeserializeID(id storage.ID, st storage.Accessor) (Element, error)

type ElementHeader

type ElementHeader struct {
	Type    Type
	Version Version
	// contains filtered or unexported fields
}

func (*ElementHeader) SetStorage

func (hdr *ElementHeader) SetStorage(st storage.Accessor)

type File

type File interface {
	Size() int64
	Reader() io.Reader
}

type FileSize

type FileSize int64

func (FileSize) String

func (size FileSize) String() string

type SimpleFile

type SimpleFile struct {
	ElementHeader
	Content []byte
}

func NewSimpleFile

func NewSimpleFile(content []byte) *SimpleFile

func (*SimpleFile) Directory

func (f *SimpleFile) Directory() *Directory

func (*SimpleFile) File

func (f *SimpleFile) File() File

func (*SimpleFile) IsDir

func (f *SimpleFile) IsDir() bool

func (*SimpleFile) Reader

func (f *SimpleFile) Reader() io.Reader

func (*SimpleFile) Serialize

func (f *SimpleFile) Serialize() ([]byte, error)

func (*SimpleFile) Size

func (f *SimpleFile) Size() int64

type SimpleReader

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

func (*SimpleReader) Read

func (r *SimpleReader) Read(p []byte) (int, error)

func (*SimpleReader) Size

func (r *SimpleReader) Size() int64

type Snapshot

type Snapshot struct {
	ElementHeader
	Timestamp int64
	Size      FileSize
	Root      storage.ID
	Parent    storage.ID
}

func NewSnapshot

func NewSnapshot() *Snapshot

func (*Snapshot) Directory

func (s *Snapshot) Directory() *Directory

func (*Snapshot) File

func (s *Snapshot) File() File

func (*Snapshot) IsDir

func (s *Snapshot) IsDir() bool

func (*Snapshot) Serialize

func (s *Snapshot) Serialize() ([]byte, error)

func (*Snapshot) String

func (s *Snapshot) String() string

type Type

type Type uint8
const (
	TypeSimpleFile Type = iota + 1
	TypeChunkedFile
	TypeDirectory
	TypeSnapshot
)

func (Type) String

func (t Type) String() string

type Version

type Version uint8

Jump to

Keyboard shortcuts

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