fs

package
v0.0.0-...-9b44dea Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2017 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NameFunc = keyPath
	HashFunc = sha1.New
)

Functions

This section is empty.

Types

type File

type File struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewFile

func NewFile(path string, namefn func(Key) string) *File

func (*File) Close

func (f *File) Close() error

Close calls Sync to flush the file to the filesystem

func (*File) Flush

func (f *File) Flush() error

func (*File) Key

func (f *File) Key() (Key, error)

Key returns the file's key. It is an error to call this method before calling Sync() or Close().

func (*File) Sync

func (f *File) Sync() error

Sync commits the File's contents to the filesystem

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

type Fs

type Fs struct {
	// NameFunc maps Keys to file names on disk. The names
	// are used to Load and Store data on the filesystem.
	NameFunc func(Key) string
	// HashFunc returns a new hash.Hash algorithm used to address
	// the underlying file contents
	HashFunc func() hash.Hash
	// contains filtered or unexported fields
}

Fs is a key value store

func New

func New(path string) *Fs

New creates a filesystem in path with a SHA1 key value store.

func (*Fs) Load

func (f *Fs) Load(k Key) (r io.ReadCloser, err error)

func (*Fs) NewFile

func (f *Fs) NewFile() (*File, error)

NewFile returns a *File satisfying io.WriteCloser. A File's data may not be committed to the filesystem until a Sync() or Close() occur.

func (*Fs) Open

func (f *Fs) Open(k Key) (r io.ReadCloser, err error)

Open resolves k using Fs.NameFunc and returns a io.ReadCloser of the underlying file contents.

func (*Fs) Store

func (f *Fs) Store() (*File, error)

type Key

type Key string

Jump to

Keyboard shortcuts

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