sivafs

package module
v4.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: Apache-2.0 Imports: 14 Imported by: 36

README

go-billy-siva GoDoc Build Status

go-billy-siva is a limit billy filesystem implementation based on siva. The implementation is limited to billy.Basic and billy.Dir, the usage of the billy.helpers is required to be able of use as a full billy.Filesystem

Installation

The recommended way to install go-billy-siva

go get -u gopkg.in/src-d/go-billy-siva.v4/...

Dependencies

It needs go-siva >= 1.4.0.

License

Apache License 2.0, see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonSeekableFile          = errors.New("file non-seekable")
	ErrFileWriteModeAlreadyOpen = errors.New("previous file in write mode already open")
	ErrReadOnlyFile             = errors.New("file is read-only")
	ErrWriteOnlyFile            = errors.New("file is write-only")
	ErrReadOnlyFilesystem       = errors.New("filesystem is read-only")
	ErrOffsetReadWrite          = errors.New("can only specify the offset in a read only filesystem")
)

Functions

This section is empty.

Types

type SivaBasicFS

type SivaBasicFS interface {
	billy.Basic
	billy.Dir

	SivaSync
}

func New

func New(fs billy.Filesystem, path string) SivaBasicFS

New creates a new filesystem backed by a siva file with the given path in the given filesystem. The siva file will be opened or created lazily with the first operation.

All files opened in write mode must be closed, otherwise the siva file will be corrupted.

func NewWithOptions added in v4.5.0

func NewWithOptions(fs billy.Filesystem, path string, o SivaFSOptions) SivaBasicFS

NewWithOptions creates a new siva backed filesystem and accepts options. See New documentation.

type SivaFS

type SivaFS interface {
	billy.Filesystem
	SivaSync
}

func NewFilesystem

func NewFilesystem(fs billy.Filesystem, path string, tmpFs billy.Filesystem) (SivaFS, error)

NewFilesystem creates an entire filesystem using siva as the main backend, but supplying unsupported functionality using as a temporal files backend the main filesystem. It needs an additional parameter `tmpFs` where temporary files will be stored. Note that `tmpFs` will be mounted as /tmp.

func NewFilesystemReadOnly added in v4.4.0

func NewFilesystemReadOnly(
	fs billy.Filesystem,
	path string,
	offset uint64,
) (SivaFS, error)

NewFilesystemReadOnly creates a read only filesystem backed by a siva file. offset is the index offset inside the siva file. Set it to 0 to use the last index.

func NewFilesystemWithOptions added in v4.5.0

func NewFilesystemWithOptions(
	fs billy.Filesystem,
	path string,
	tmpFs billy.Filesystem,
	o SivaFSOptions,
) (SivaFS, error)

NewFilesystemWithOptions creates an entire filesystem siva as the main backend. It accepts options. See NewFilesystem documentation.

type SivaFSOptions added in v4.5.0

type SivaFSOptions struct {
	// UnsafePaths set to on does not sanitize file paths.
	UnsafePaths bool
	// ReadOnly opens the siva file in read only mode.
	ReadOnly bool
	// Offset specifies the offset of the index. If it is 0 then the latest
	// index is used. This is only usable in read only mode.
	Offset uint64
}

SivaFSOptions holds configuration options for the filesystem.

type SivaSync

type SivaSync interface {
	// Sync closes any open files, this method should be called at the end of
	// program to ensure that all the files are properly closed, otherwise the
	// siva file will be corrupted.
	Sync() error
}

Jump to

Keyboard shortcuts

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