Documentation ¶
Overview ¶
Package vfs provides Virtual FileSystem (VFS) capability. Typically it reflects OS FileSystem behavior in-memory.
aah vfs is Read-Only, even though vfs design nature could support Write operations. I have limited it.
The methods should behave the same as those on an *os.File for Read-Only.
Index ¶
- Constants
- Variables
- func Glob(fs *VFS, pattern string) ([]string, error)
- func IsExists(fs *VFS, name string) bool
- func Lstat(fs *VFS, name string) (os.FileInfo, error)
- func ReadDir(fs *VFS, dirname string) ([]os.FileInfo, error)
- func ReadFile(fs *VFS, filename string) ([]byte, error)
- func Stat(fs *VFS, name string) (os.FileInfo, error)
- func Walk(fs *VFS, root string, walkFn filepath.WalkFunc) error
- type File
- type FileSystem
- type Gziper
- type Mount
- func (m *Mount) AddDir(fi os.FileInfo) error
- func (m *Mount) AddFile(fi os.FileInfo, data []byte) error
- func (m Mount) Glob(pattern string) ([]string, error)
- func (m Mount) IsExists(name string) bool
- func (m Mount) Lstat(name string) (os.FileInfo, error)
- func (m *Mount) Name() string
- func (m Mount) Open(name string) (File, error)
- func (m Mount) ReadDir(dirname string) ([]os.FileInfo, error)
- func (m Mount) ReadFile(name string) ([]byte, error)
- func (m Mount) Stat(name string) (os.FileInfo, error)
- func (m Mount) String() string
- type NodeInfo
- type RawBytes
- type VFS
- func (v *VFS) AddMount(mountPath, physicalPath string) error
- func (v *VFS) Dirs(root string) ([]string, error)
- func (v *VFS) Files(root string) ([]string, error)
- func (v *VFS) FindMount(name string) (*Mount, error)
- func (v *VFS) Glob(pattern string) ([]string, error)
- func (v *VFS) IsEmbeddedMode() bool
- func (v *VFS) IsExists(name string) bool
- func (v *VFS) Lstat(name string) (os.FileInfo, error)
- func (v *VFS) Open(name string) (File, error)
- func (v *VFS) ReadDir(dirname string) ([]os.FileInfo, error)
- func (v *VFS) ReadFile(filename string) ([]byte, error)
- func (v *VFS) SetEmbeddedMode()
- func (v *VFS) Stat(name string) (os.FileInfo, error)
- func (v *VFS) Walk(root string, walkFn filepath.WalkFunc) error
Constants ¶
const Version = "0.2.0"
Version no. of Virtual FileSystem (VFS) library by aah framework.
Variables ¶
var ( ErrMountExists = errors.New("vfs: mount already exists") ErrMountNotExists = errors.New("vfs: mount does not exist") ErrNotAbsolutPath = errors.New("vfs: not a absolute path") )
VFS errors
Functions ¶
func Glob ¶
Glob method calls `filepath.Glob` if fs == nil otherwise VFS.
NOTE: Use VFS instance directly `aah.AppVFS().*`. This is created to prevent repetition code in consumimg libraries of aah.
func IsExists ¶
IsExists method is helper to find existence.
NOTE: Use VFS instance directly `aah.AppVFS().*`. This is created to prevent repetition code in consumimg libraries of aah.
func Lstat ¶
Lstat method calls `os.Lstat` if fs == nil otherwise VFS.
NOTE: Use VFS instance directly `aah.AppVFS().*`. This is created to prevent repetition code in consumimg libraries of aah.
func ReadDir ¶
ReadDir method calls `ioutil.ReadDir` if fs == nil otherwise VFS.
NOTE: Use VFS instance directly `aah.AppVFS().*`. This is created to prevent repetition code in consumimg libraries of aah.
func ReadFile ¶
ReadFile method calls `ioutil.ReadFile` if fs == nil otherwise VFS.
NOTE: Use VFS instance directly `aah.AppVFS().*`. This is created to prevent repetition code in consumimg libraries of aah.
Types ¶
type FileSystem ¶
type FileSystem interface { Open(name string) (File, error) Lstat(name string) (os.FileInfo, error) Stat(name string) (os.FileInfo, error) ReadFile(filename string) ([]byte, error) ReadDir(dirname string) ([]os.FileInfo, error) Glob(pattern string) ([]string, error) IsExists(name string) bool }
FileSystem interface implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention.
type Mount ¶
Mount struct represents mount of single physical directory into virtual directory.
Mount implements `vfs.FileSystem`, its a combination of package `os` and `ioutil` focused on Read-Only operations.
func (*Mount) AddDir ¶
AddDir method is to add directory node into VFS from mounted source directory.
func (Mount) Glob ¶
Glob method somewhat similar to `filepath.Glob`, since aah vfs does pattern match only on `filepath.Base` value.
type NodeInfo ¶
NodeInfo is used to collect `os.FileInfo` values during binary generation.
type RawBytes ¶ added in v0.2.0
type RawBytes interface {
RawBytes() []byte
}
RawBytes interface is to retrieve underlying file's raw bytes.
Note: It could be gzip or non-gzip bytes. Use interface `Gziper` to identify byte classification.
type VFS ¶
type VFS struct {
// contains filtered or unexported fields
}
VFS represents Virtual FileSystem (VFS), it operates in-memory. if file/directory doesn't exists on in-memory then it tries physical filesystem.
VFS implements `vfs.FileSystem`, its a combination of package `os` and `ioutil` focused on Read-Only operations.
Single point of access for all mounted virtual directories in aah application.
func (*VFS) AddMount ¶
AddMount method used to mount physical directory as a virtual mounted directory.
Basically aah scans and application source files and builds each file from mounted source directory into binary for single binary build.
func (*VFS) FindMount ¶
FindMount method finds the mounted virtual directory by mount path. if found then returns `Mount` instance otherwise nil and error.
Mount implements `vfs.FileSystem`, its a combination of package `os` and `ioutil` focused on Read-Only operations.
func (*VFS) Glob ¶
Glob method somewhat similar to `filepath.Glob`, since aah vfs does pattern match only on `filepath.Base` value.
func (*VFS) IsEmbeddedMode ¶ added in v0.1.2
IsEmbeddedMode method returns true if its a single binary otherwise false.
func (*VFS) SetEmbeddedMode ¶ added in v0.1.2
func (v *VFS) SetEmbeddedMode()
SetEmbeddedMode method set the VFS into Embedded Mode. It means single binary.