btrfs

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2015 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Desc = iota
	Asc
)

Constants used for passing to log

Variables

View Source
var (
	ErrComplete  = errors.New("pfs: complete")
	ErrCancelled = errors.New("pfs: cancelled")
)

Functions

func Append

func Append(name string, r io.Reader) (int64, error)

Append reads data out of reader and appends it to the file. If the file doesn't exist it creates it.

func Before

func Before(name1, name2 string) (bool, error)

Before eturn true if name1 was last modified before name2

func Branch

func Branch(repo, commit, branch string) error

Branch creates a new writeable branch from commit.

func Changed

func Changed(name string, mtime time.Time) (bool, error)

Changed returns true if `mtime` is after the filesystem time for name

func CheckVersion added in v0.9.0

func CheckVersion() error

func Chtimes

func Chtimes(name string, atime, mtime time.Time) error

Chtimes changes the access and modification times of a file

func Commit

func Commit(repo, commit, branch string) error

Commit creates a new commit on a branch. The contents of the commit will be the same as the current contents of the branch.

func Commits

func Commits(repo, from string, order int, cont func(string) error) error

Commits is a wrapper around `Log` which parses the output in to a convenient struct

func CopyFile

func CopyFile(name string, r io.Reader) (int64, error)

CopyFile copies the contents of `r` in the a file

func Create

func Create(name string) (*os.File, error)

Create creates a new file in the btrfs volume

func CreateAll

func CreateAll(name string) (*os.File, error)

CreateAll is like create but it will create the directory for the file if it doesn't already exist.

func CreateFromReader

func CreateFromReader(name string, r io.Reader) (int64, error)

CreateFromReader is like Create but automatically sets the content of the file to the data found in `r`

func DanglingCommit

func DanglingCommit(repo, commit, branch string) error

DanglingCommit creates a commit but resets the branch to point to its current parent

func DeleteCommit added in v0.9.0

func DeleteCommit(commit string) error

func Ensure

func Ensure(repo string) error

Ensure is like Init but won't error if the repo is already present. It will error if the repo is not present and we fail to make it.

func FileExists

func FileExists(name string) (bool, error)

FileExists returns true if a file exists in the filesystem

func FilePath

func FilePath(name string) string

FilePath returns an absolute path for a file in the btrfs volume *inside* the container.

func FindNew

func FindNew(repo, from, to string) ([]string, error)

FindNew returns an array of filenames that were created or modified between `from` and `to`

func GetMeta

func GetMeta(name, key string) string

GetMeta gets metadata from a commit or branch

func Glob

func Glob(pattern string) ([]string, error)

Glob returns the names of all files matching pattern or nil if there's no match. Glob uses syntax that should be familiar from shell like /foo/bar/*

func HostPath

func HostPath(name string) string

HostPath returns an absolute for a file *outside* the container

func Init

func Init(repo string) error

Init initializes an empty repo.

func IsCommit added in v0.9.0

func IsCommit(name string) (bool, error)

IsCommit returns true if the volume is a commit and false if it's a branch.

func Lstat

func Lstat(name string) (os.FileInfo, error)

Lstat returns FileInfo describing a file, if the file is a symbolic link it still works.

func Mkdir

func Mkdir(name string) error

Mkdir creates a directory

func MkdirAll

func MkdirAll(name string) error

MkdirAll creates a directory and all parent directories

func NewIn

func NewIn(repo, commit string) ([]string, error)

NewIn returns all of the files that changed in a commit

func Open

func Open(name string) (*os.File, error)

Open opens a file for reading.

func OpenFd

func OpenFd(name string, mode int, perm uint32) (int, error)

OpenFd opens a file and gives you the file descriptor.

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile is a generalize form of Open

func Pull

func Pull(repo, from string, cb Pusher) error

Pull produces a binary diff stream from repo and passes it to cb

func ReadDir

func ReadDir(name string) ([]os.FileInfo, error)

ReadDir returns a list of files found in the name directory

func ReadFile

func ReadFile(name string) ([]byte, error)

ReadFile returns the contents of a file.

func Remove

func Remove(name string) error

Remove removes a file or directory

func RemoveAll

func RemoveAll(name string) error

RemoveAll removes a path and any children it contains

func Rename

func Rename(oldname, newname string) error

Rename renames a file

func SetMeta

func SetMeta(branch, key, value string) error

SetMeta sets metadata for a branch

func Show added in v0.9.0

func Show(repo string, commit string, out string) error

func Stat

func Stat(name string) (os.FileInfo, error)

Stat returns a FileInfo describing a file.

func WaitAnyFile

func WaitAnyFile(files ...string) (string, error)

WaitAnyFile returns as soon as ANY of the files exists. It returns an error if waiting for ANY of the files errors.

func WaitFile

func WaitFile(name string, cancel chan struct{}) error

WaitFile waits for a file to exist in the filesystem NOTE: You NEVER want to pass an unbuffered channel as cancel because WaitFile provides no guarantee that it will ever read from cancel. Thus if you passed an unbuffered channel as cancel sending to the channel may block forever.

func WriteFile

func WriteFile(name string, data []byte) error

Writefile sets the contents of a file to `data`

Types

type Puller

type Puller interface {
	// Pull produces binary diffs and passes them to p's Push method.
	Pull(from string, p Pusher) error
}

Puller is an interface that wraps the Pull method.

type Pusher

type Pusher interface {
	// From returns the last commit pushed.
	// This value should be passed to Pull.
	From() (string, error)
	// Push applies diff to an underlying storage layer.
	Push(diff io.Reader) error
}

Pusher is an interface that wraps the Push method.

type Replica

type Replica interface {
	Pusher
	Puller
}

Replica is the interface that groups the Puller and Pusher methods.

func NewLocalReplica

func NewLocalReplica(repo string) Replica

func NewS3Replica

func NewS3Replica(uri string) Replica

Jump to

Keyboard shortcuts

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