Documentation
¶
Index ¶
Constants ¶
const FromTheCurrentOffset = 1
FromTheCurrentOffset is a constant that can be used for 'whence' in the Seek method.
const FromTheEnd = 2
FromTheEnd is a constant that can be used for 'whence' in the Seek method.
const FromTheStart = 0
FromTheStart is a constant that can be used for 'whence' in the Seek method.
Variables ¶
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.
var ErrOffsetBeyondBounds = errors.New("offset beyond bounds error")
ErrOffsetBeyondBounds occurs when attempting to read outside the bounds of the backing file bytes.
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.
var ErrPathNotAbsolute = errors.New("asset mount not absolute path error")
ErrPathNotAbsolute occurs when a new FileSystem isn't rooted via an absolute path.
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.
type EmbeddedFileSystem ¶
type EmbeddedFileSystem struct {
// contains filtered or unexported fields
}
EmbeddedFileSystem provides a FileSystem over embedded assets.
type File ¶
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 ¶
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 ¶
InfoProvider is a function signature for obtaining FileInfo instances.
type OpenProvider ¶
OpenProvider is a function signature for opening files to be read from the file system.