vfs.v0: aahframework.org/vfs.v0 Index | Files

package vfs

import "aahframework.org/vfs.v0"

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

Package Files

file.go fs.go mount.go node.go util.go version.go vfs.go

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

func Glob Uses

func Glob(fs *VFS, pattern string) ([]string, error)

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 Uses

func IsExists(fs *VFS, name string) bool

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 Uses

func Lstat(fs *VFS, name string) (os.FileInfo, error)

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 Uses

func ReadDir(fs *VFS, dirname string) ([]os.FileInfo, error)

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 Uses

func ReadFile(fs *VFS, filename string) ([]byte, error)

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.

func Stat Uses

func Stat(fs *VFS, name string) (os.FileInfo, error)

Stat method calls `os.Stat` 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 Walk Uses

func Walk(fs *VFS, root string, walkFn filepath.WalkFunc) error

Walk method calls `filepath.Walk` if fs == nil otherwise VFS.

NOTE: Use VFS instance directly `aah.AppVFS().*`. This is created to prevent repetition code in consumimg libraries of aah.

type File Uses

type File interface {
    http.File
    Readdirnames(n int) ([]string, error)
}

File interface returned by a vfs.FileSystem's Open method.

func Open Uses

func Open(fs *VFS, name string) (File, error)

Open method calls `os.Open` if fs == nil otherwise VFS.

NOTE: Use VFS instance directly `aah.AppVFS().*`. This is created to prevent repetition code in consumimg libraries of aah.

type FileSystem Uses

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 Gziper Uses

type Gziper interface {
    RawBytes
    IsGzip() bool
}

Gziper interface is to identify whether the file's raw bytes is gzipped or not.

type Mount Uses

type Mount struct {
    Vroot string
    Proot string
    // contains filtered or unexported fields
}

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 Uses

func (m *Mount) AddDir(fi os.FileInfo) error

AddDir method is to add directory node into VFS from mounted source directory.

func (*Mount) AddFile Uses

func (m *Mount) AddFile(fi os.FileInfo, data []byte) error

AddFile method is to add file node into VFS from mounted source directory.

func (Mount) Glob Uses

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

Glob method somewhat similar to `filepath.Glob`, since aah vfs does pattern match only on `filepath.Base` value.

func (Mount) IsExists Uses

func (m Mount) IsExists(name string) bool

IsExists method is helper to find existence.

func (Mount) Lstat Uses

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

Lstat method behaviour is same as `os.Lstat`.

func (*Mount) Name Uses

func (m *Mount) Name() string

Name method returns mounted path.

func (Mount) Open Uses

func (m Mount) Open(name string) (File, error)

Open method behaviour is same as `os.Open`.

func (Mount) ReadDir Uses

func (m Mount) ReadDir(dirname string) ([]os.FileInfo, error)

ReadDir method behaviour is same as `ioutil.ReadDir`.

func (Mount) ReadFile Uses

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

ReadFile method behaviour is same as `ioutil.ReadFile`.

func (Mount) Stat Uses

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

Stat method behaviour is same as `os.Stat`

func (Mount) String Uses

func (m Mount) String() string

String method Stringer interface.

type NodeInfo Uses

type NodeInfo struct {
    Dir      bool
    DataSize int64
    Path     string
    Time     time.Time
}

NodeInfo is used to collect `os.FileInfo` values during binary generation.

func (NodeInfo) IsDir Uses

func (n NodeInfo) IsDir() bool

IsDir method returns whether node is dierctory or not.

func (NodeInfo) ModTime Uses

func (n NodeInfo) ModTime() time.Time

ModTime method returns modification time.

func (NodeInfo) Mode Uses

func (n NodeInfo) Mode() os.FileMode

Mode method returns file mode bits.

func (NodeInfo) Name Uses

func (n NodeInfo) Name() string

Name method returns base name of the file/directory.

func (NodeInfo) Size Uses

func (n NodeInfo) Size() int64

Size method returns length in bytes for regular files; system-dependent for others

func (NodeInfo) Sys Uses

func (n NodeInfo) Sys() interface{}

Sys method returns nil.

type RawBytes Uses

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 Uses

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 Uses

func (v *VFS) AddMount(mountPath, physicalPath string) error

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) Dirs Uses

func (v *VFS) Dirs(root string) ([]string, error)

Dirs method returns directories path recursively for given root path.

func (*VFS) Files Uses

func (v *VFS) Files(root string) ([]string, error)

Files method returns directories path recursively for given root path.

func (*VFS) FindMount Uses

func (v *VFS) FindMount(name string) (*Mount, error)

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 Uses

func (v *VFS) Glob(pattern string) ([]string, error)

Glob method somewhat similar to `filepath.Glob`, since aah vfs does pattern match only on `filepath.Base` value.

func (*VFS) IsEmbeddedMode Uses

func (v *VFS) IsEmbeddedMode() bool

IsEmbeddedMode method returns true if its a single binary otherwise false.

func (*VFS) IsExists Uses

func (v *VFS) IsExists(name string) bool

IsExists method is helper to find existence.

func (*VFS) Lstat Uses

func (v *VFS) Lstat(name string) (os.FileInfo, error)

Lstat method behaviour is same as `os.Lstat`.

func (*VFS) Open Uses

func (v *VFS) Open(name string) (File, error)

Open method behaviour is same as `os.Open`.

func (*VFS) ReadDir Uses

func (v *VFS) ReadDir(dirname string) ([]os.FileInfo, error)

ReadDir method behaviour is same as `ioutil.ReadDir`.

func (*VFS) ReadFile Uses

func (v *VFS) ReadFile(filename string) ([]byte, error)

ReadFile method behaviour is same as `ioutil.ReadFile`.

func (*VFS) SetEmbeddedMode Uses

func (v *VFS) SetEmbeddedMode()

SetEmbeddedMode method set the VFS into Embedded Mode. It means single binary.

func (*VFS) Stat Uses

func (v *VFS) Stat(name string) (os.FileInfo, error)

Stat method behaviour is same as `os.Stat`

func (*VFS) Walk Uses

func (v *VFS) Walk(root string, walkFn filepath.WalkFunc) error

Walk method behaviour is same as `filepath.Walk`.

Package vfs imports 13 packages (graph) and is imported by 8 packages. Updated 2018-06-18. Refresh now. Tools for package owners.