filetree

package
v0.0.0-...-e8b74a0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirMapping

type DirMapping struct {
	PlaintextPath  string
	CiphertextPath string
	// contains filtered or unexported fields
}

type FSAccessor

type FSAccessor interface {
	ReadFile(path string) ([]byte, error)
	Stat(path string) (os.FileInfo, error)
	ReadDir(path string) ([]os.FileInfo, error)
}

FSAccessor defines an accessor to the real underlying filesystem

type FastCache

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

func NewFastCache

func NewFastCache(cacheSize int) *FastCache

func (*FastCache) Clear

func (f *FastCache) Clear()

Clear removes all entries from the fast cache and the tree cache.

func (*FastCache) Find

func (f *FastCache) Find(pPath string) (DirMapping, bool)

Find tries to find the given plaintext directory in the cache, returning false if it is not found. Because FastCache is an LRU cache, successfully resolving the entry will make it the most recently used entry in the cache.

func (*FastCache) Store

func (f *FastCache) Store(pPath, cPath string)

Store stores the given directory mapping in the fast cache. The cache behaves like an LRU cache with a capacity of 16 entries. When storing an entry would cause the cache to exceed its capacity, it will evict the least recently used item in the cache.

This could technically be used for files, but it's probably more efficient to use for directories.

type FileTree

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

FileTree provides a plaintext view of the filesystem provided by fsAccessor

func Init

func Init(
	encryptedRoot string,
	password []byte,
	numWorkers int,
	fsAccessor FSAccessor,
) (*FileTree, error)

func (*FileTree) Mkdir

func (f *FileTree) Mkdir(plainPath string) error

func (*FileTree) ReadDir

func (f *FileTree) ReadDir(plainPath string) ([]os.FileInfo, error)

func (*FileTree) ReadFile

func (f *FileTree) ReadFile(plainPath string) ([]byte, error)

func (*FileTree) Remove

func (f *FileTree) Remove(plainPath string) error

func (*FileTree) Rename

func (f *FileTree) Rename(plainPath string, target string) error

func (*FileTree) Stat

func (f *FileTree) Stat(plainPath string) (os.FileInfo, error)

func (*FileTree) WriteFile

func (f *FileTree) WriteFile(plainPath string, data []byte) (int64, error)

Jump to

Keyboard shortcuts

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