proxyfs

package module
v0.0.0-...-ead3718 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: EPL-1.0 Imports: 6 Imported by: 0

README

#+BEGIN_HTML
<img src="https://goreportcard.com/badge/github.com/lcaballero/proxyfs" 
     tag="https://goreportcard.com/badge/github.com/lcaballero/proxyfs" />

<a href="https://godoc.org/github.com/lcaballero/proxyfs">
   <img src="https://godoc.org/github.com/lcaballero/proxyfs?status.svg" alt="GoDoc"/>
</a>

<img src="https://travis-ci.org/lcaballero/proxyfs.svg?branch=master"/>
#+END_HTML

* Introduction

`proxyfs` is a read-once then cached file system intended to mount a
file directory.  Load of the content is deferred until the file is
requested.  Content changes are not intended to be written via
this interface.

Documentation

Index

Constants

View Source
const FromTheCurrentOffset = 1

FromTheCurrentOffset is a constant that can be used for 'whence' in the Seek method.

View Source
const FromTheEnd = 2

FromTheEnd is a constant that can be used for 'whence' in the Seek method.

View Source
const FromTheStart = 0

FromTheStart is a constant that can be used for 'whence' in the Seek method.

Variables

View Source
var ErrNegativeReadOffsetAfterSeek = errors.New("negative read offset after seek")

ErrNegativeReadOffsetAfterSeek occurs if the next read offset after a call to Seek is would be negative.

View Source
var ErrOffsetBeyondBounds = errors.New("offset beyond bounds error")

ErrOffsetBeyondBounds occurs when attempting to read outside the bounds of the backing file bytes.

View Source
var ErrOffsetGreaterThanFileSizeAfterSeek = errors.New("offset greater then file length after seek")

ErrOffsetGreaterThanFileSizeAfterSeek occurs if the next read offset is beyond the end of the file after a Seek call.

View Source
var ErrPathNotAbsolute = errors.New("asset mount not absolute path error")

ErrPathNotAbsolute occurs when a new FileSystem isn't rooted via an absolute path.

View Source
var ErrProviderIsNil = errors.New("provider is nil error")

ErrProviderIsNil occurs when a provider to NewEmbeddedFileSystem is nil

Functions

This section is empty.

Types

type CachedFile

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

A CachedFile represents

func (*CachedFile) Close

func (c *CachedFile) Close() error

Close always returns nil since any error had to of occurred before when when Open on the FileSystem was called.

func (*CachedFile) Read

func (c *CachedFile) Read(p []byte) (n int, err error)

Read implements io.Read function but over a CachedFile. After using this method to read a file the mark will be set at the end of the file, so in order to reset it use the Seek method below.

func (*CachedFile) ReadAt

func (c *CachedFile) ReadAt(p []byte, off int64) (n int, err error)

ReadAt fills the destination slice with bytes from the file starting at the provided offset, reading up to dest length, or the remainder of bytes in the file. The number of bytes read and an error should one occur is returned.

func (*CachedFile) Seek

func (c *CachedFile) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seek interface over a CachedFile.

func (*CachedFile) Stat

func (c *CachedFile) Stat() (FileInfo, error)

Stat implements the Stat from the File interface.

type CachedFileSystem

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

CachedFileSystem implements the FileSystem interface.

func (*CachedFileSystem) Open

func (c *CachedFileSystem) Open(name string) (File, error)

Open maps the given name to a file rooted at the mount point of the CachedFileSystem returning a File if it exists or an error if one occurs while reading the file.

type EmbeddedFileSystem

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

EmbeddedFileSystem provides a FileSystem over embedded assets.

func (*EmbeddedFileSystem) Open

func (c *EmbeddedFileSystem) Open(name string) (File, error)

Open provides a file from the EmbeddedFileSystem else and error if the given file name could not be found.

type File

type File interface {
	io.Closer
	io.Reader
	io.ReaderAt
	io.Seeker
	Stat() (FileInfo, error)
}

File is an abstraction over actual Files on the system provided by a FileSystem implementation.

type FileInfo

type FileInfo interface {
	Name() string
	Size() int64
	Mode() os.FileMode
	ModTime() time.Time
	IsDir() bool
	Sys() interface{}
}

FileInfo interface provided to match the os.FileInfo object.

type FileSystem

type FileSystem interface {
	Open(name string) (File, error)
}

FileSystem provides the Open method to obtain File instances that abstract a file system, much like os.Open provides FileInfo structs.

func NewCachedFileSystem

func NewCachedFileSystem(root string) (FileSystem, error)

NewCachedFileSystem creates a FileSystem over the given directory, which must be an absolute path. If the directory provided is not absolute an error.

func NewEmbeddedFileSystem

func NewEmbeddedFileSystem(
	open OpenProvider,
	info InfoProvider) (FileSystem, error)

NewEmbeddedFileSystem creates a new FileSystem with the given functions that open and provide file-info.

type InfoProvider

type InfoProvider func(string) (os.FileInfo, error)

InfoProvider is a function signature for obtaining FileInfo instances.

type OpenProvider

type OpenProvider func(string) ([]byte, error)

OpenProvider is a function signature for opening files to be read from the file system.

Jump to

Keyboard shortcuts

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