Documentation ¶
Index ¶
- Constants
- Variables
- func NewEmbedFS(fs embed.FS) fi.FileSystem
- func Recursive(raw string, opts ...Option) error
- type Config
- type DirStat
- type Event
- type EventSet
- type FileNode
- type FileStat
- type LocalFs
- func (f *LocalFs) Delete(name string) error
- func (f *LocalFs) Exists(path string) (bool, error)
- func (f *LocalFs) Ext(s string) string
- func (f *LocalFs) GetSeparators() rune
- func (f *LocalFs) Getwd() (string, error)
- func (f *LocalFs) IsAbs(name string) bool
- func (f *LocalFs) Join(paths ...string) string
- func (f *LocalFs) MkdirAll(name string, perm os.FileMode) error
- func (f *LocalFs) Open(name string) (fs.File, error)
- func (f *LocalFs) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error)
- func (f *LocalFs) PathSplit(s string) (string, string)
- func (f *LocalFs) ReadDir(dirname string) ([]fs.DirEntry, error)
- func (f *LocalFs) ReadFile(name string) ([]byte, error)
- func (f *LocalFs) Rel(base string, target string) (string, error)
- func (f *LocalFs) Rename(old string, new string) error
- func (f *LocalFs) Stat(name string) (fs.FileInfo, error)
- func (f *LocalFs) Throw(filenames ...string) error
- func (f *LocalFs) WriteFile(name string, data []byte, perm os.FileMode) error
- type MonitorEventHandler
- type Option
- func WithDir(globDir string, opts ...Option) Option
- func WithDirStat(f DirStat) Option
- func WithDirWalkEnd(handle func(path string) error) Option
- func WithEmbedFS(f embed.FS) Option
- func WithFileStat(f FileStat) Option
- func WithFileSystem(f fi.FileSystem) Option
- func WithOnStart(f func(basename string, isDir bool) error) Option
- func WithRecursiveDirectory(b bool) Option
- func WithStat(f func(isDir bool, pathname string, info os.FileInfo) error) Option
- type RelLocalFs
- func (f *RelLocalFs) Delete(name string) error
- func (f *RelLocalFs) Exists(path string) (bool, error)
- func (f *RelLocalFs) Ext(s string) string
- func (f *RelLocalFs) GetSeparators() rune
- func (f *RelLocalFs) Getwd() (string, error)
- func (f *RelLocalFs) IsAbs(name string) bool
- func (f *RelLocalFs) Join(paths ...string) string
- func (f *RelLocalFs) MkdirAll(name string, perm os.FileMode) error
- func (f *RelLocalFs) Open(name string) (fs.File, error)
- func (f *RelLocalFs) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error)
- func (f *RelLocalFs) PathSplit(s string) (string, string)
- func (f *RelLocalFs) ReadDir(dirname string) ([]fs.DirEntry, error)
- func (f *RelLocalFs) ReadFile(name string) ([]byte, error)
- func (f *RelLocalFs) Rel(base string, target string) (string, error)
- func (f *RelLocalFs) Rename(old string, new string) error
- func (f *RelLocalFs) Stat(name string) (fs.FileInfo, error)
- func (f *RelLocalFs) String() string
- func (f *RelLocalFs) WriteFile(name string, data []byte, perm os.FileMode) error
- type VirtualFS
- func (f *VirtualFS) AddDir(dirName string) *VirtualFile
- func (f *VirtualFS) AddFile(name, content string)
- func (f *VirtualFS) Delete(path string) error
- func (f *VirtualFS) Exists(path string) (bool, error)
- func (f *VirtualFS) Ext(s string) string
- func (f *VirtualFS) GetLocalFSPath() string
- func (f *VirtualFS) GetSeparators() rune
- func (f *VirtualFS) Getwd() (string, error)
- func (f *VirtualFS) IsAbs(name string) bool
- func (f *VirtualFS) Join(name ...string) string
- func (f *VirtualFS) MkdirAll(path string, mode os.FileMode) error
- func (f *VirtualFS) Open(name string) (fs.File, error)
- func (f *VirtualFS) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error)
- func (f *VirtualFS) PathSplit(s string) (string, string)
- func (f *VirtualFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (f *VirtualFS) ReadFile(name string) ([]byte, error)
- func (f *VirtualFS) Rel(string, string) (string, error)
- func (f *VirtualFS) RemoveFileOrDir(name string) error
- func (f *VirtualFS) Rename(string, string) error
- func (f *VirtualFS) Stat(name string) (fs.FileInfo, error)
- func (f *VirtualFS) WriteFile(name string, data []byte, mode os.FileMode) error
- type VirtualFile
- type VirtualFileInfo
- func (vi *VirtualFileInfo) Info() (fs.FileInfo, error)
- func (vi *VirtualFileInfo) IsDir() bool
- func (vi *VirtualFileInfo) ModTime() time.Time
- func (vi *VirtualFileInfo) Mode() os.FileMode
- func (vi *VirtualFileInfo) Name() string
- func (vi *VirtualFileInfo) Size() int64
- func (vi *VirtualFileInfo) Sys() any
- func (vi *VirtualFileInfo) Type() fs.FileMode
- type YakFileMonitor
- type ZipDirEntry
- type ZipFS
- func (z *ZipFS) Clean(name string) string
- func (z *ZipFS) Delete(s string) error
- func (z *ZipFS) Exists(s string) (bool, error)
- func (z *ZipFS) Ext(i string) string
- func (z *ZipFS) GetSeparators() rune
- func (z *ZipFS) Getwd() (string, error)
- func (z *ZipFS) IsAbs(s string) bool
- func (z *ZipFS) Join(name ...string) string
- func (z *ZipFS) MkdirAll(s string, mode os.FileMode) error
- func (z *ZipFS) Open(name string) (fs.File, error)
- func (z *ZipFS) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error)
- func (z *ZipFS) PathSplit(s string) (string, string)
- func (z *ZipFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (z *ZipFS) ReadFile(name string) ([]byte, error)
- func (z *ZipFS) Rel(s string, s2 string) (string, error)
- func (z *ZipFS) Rename(s string, s2 string) error
- func (z *ZipFS) Stat(name string) (fs.FileInfo, error)
- func (z *ZipFS) WriteFile(s string, bytes []byte, mode os.FileMode) error
Constants ¶
View Source
const ( FsMonitorCreate = "create" // dir FsMonitorWrite = "write" FsMonitorRename = "rename" FsMonitorRemove = "remove" FsMonitorChmod = "chmod" FsMonitorChange = "change" FsMonitorTouch = "touch" FsMonitorDelete = "delete" )
Variables ¶
View Source
var Exports = map[string]any{ "Recursive": Recursive, "onReady": withYaklangOnStart, "onStat": withYaklangStat, "onFileStat": withYaklangFileStat, "onDirStat": withYaklangDirStat, "dir": WithDir, }
View Source
var SkipAll = errors.New("skip all")
View Source
var SkipDir = errors.New("skip dir")
Functions ¶
func NewEmbedFS ¶ added in v1.3.3
func NewEmbedFS(fs embed.FS) fi.FileSystem
Types ¶
type Config ¶
type Config struct { RecursiveDirectory bool // contains filtered or unexported fields }
type EventSet ¶
func CompareFileTree ¶
type FileNode ¶
type FileNode struct { Info os.FileInfo Path string Children map[string]*FileNode Parent *FileNode IsRoot bool }
func GetCurrentFileTree ¶
type LocalFs ¶ added in v1.3.3
type LocalFs struct {
// contains filtered or unexported fields
}
local FileSystem
func NewLocalFs ¶ added in v1.3.3
func NewLocalFs() *LocalFs
func (*LocalFs) GetSeparators ¶ added in v1.3.3
type MonitorEventHandler ¶
type MonitorEventHandler func(events *EventSet)
type Option ¶
type Option func(*Config)
func WithDirStat ¶
func WithDirWalkEnd ¶
func WithEmbedFS ¶
func WithFileStat ¶
func WithFileSystem ¶
func WithFileSystem(f fi.FileSystem) Option
func WithRecursiveDirectory ¶ added in v1.3.3
type RelLocalFs ¶
type RelLocalFs struct {
// contains filtered or unexported fields
}
func NewRelLocalFs ¶
func NewRelLocalFs(rel string) *RelLocalFs
func (*RelLocalFs) Delete ¶
func (f *RelLocalFs) Delete(name string) error
func (*RelLocalFs) Ext ¶
func (f *RelLocalFs) Ext(s string) string
func (*RelLocalFs) GetSeparators ¶
func (f *RelLocalFs) GetSeparators() rune
func (*RelLocalFs) Getwd ¶
func (f *RelLocalFs) Getwd() (string, error)
func (*RelLocalFs) IsAbs ¶
func (f *RelLocalFs) IsAbs(name string) bool
func (*RelLocalFs) Join ¶
func (f *RelLocalFs) Join(paths ...string) string
func (*RelLocalFs) String ¶
func (f *RelLocalFs) String() string
type VirtualFS ¶ added in v1.3.3
type VirtualFS struct {
// contains filtered or unexported fields
}
func NewVirtualFs ¶ added in v1.3.3
func NewVirtualFs() *VirtualFS
func (*VirtualFS) AddDir ¶ added in v1.3.3
func (f *VirtualFS) AddDir(dirName string) *VirtualFile
func (*VirtualFS) GetLocalFSPath ¶ added in v1.3.3
func (*VirtualFS) GetSeparators ¶ added in v1.3.3
func (*VirtualFS) RemoveFileOrDir ¶ added in v1.3.3
type VirtualFile ¶ added in v1.3.3
type VirtualFile struct {
// contains filtered or unexported fields
}
func NewVirtualFile ¶ added in v1.3.3
func NewVirtualFile(name string, content string) *VirtualFile
func NewVirtualFileDirectory ¶ added in v1.3.3
func NewVirtualFileDirectory(dirName string, dir *VirtualFS) *VirtualFile
func (*VirtualFile) Close ¶ added in v1.3.3
func (vf *VirtualFile) Close() error
func (*VirtualFile) FS ¶
func (f *VirtualFile) FS() fi.FileSystem
type VirtualFileInfo ¶ added in v1.3.3
type VirtualFileInfo struct {
// contains filtered or unexported fields
}
func NewVirtualFileInfo ¶ added in v1.3.3
func NewVirtualFileInfo(name string, size int64, isDir bool) *VirtualFileInfo
func (*VirtualFileInfo) Info ¶ added in v1.3.3
func (vi *VirtualFileInfo) Info() (fs.FileInfo, error)
func (*VirtualFileInfo) IsDir ¶ added in v1.3.3
func (vi *VirtualFileInfo) IsDir() bool
func (*VirtualFileInfo) ModTime ¶ added in v1.3.3
func (vi *VirtualFileInfo) ModTime() time.Time
func (*VirtualFileInfo) Mode ¶ added in v1.3.3
func (vi *VirtualFileInfo) Mode() os.FileMode
func (*VirtualFileInfo) Name ¶ added in v1.3.3
func (vi *VirtualFileInfo) Name() string
func (*VirtualFileInfo) Size ¶ added in v1.3.3
func (vi *VirtualFileInfo) Size() int64
func (*VirtualFileInfo) Sys ¶ added in v1.3.3
func (vi *VirtualFileInfo) Sys() any
func (*VirtualFileInfo) Type ¶ added in v1.3.3
func (vi *VirtualFileInfo) Type() fs.FileMode
type YakFileMonitor ¶
type YakFileMonitor struct { Events chan *EventSet RecursiveFinish chan struct{} // recursive finish FileTreeMutex sync.Mutex FileTree *FileNode WatchPatch string Ctx context.Context CancelFunc context.CancelFunc }
func WatchPath ¶
func WatchPath(ctx context.Context, path string, eventHandler MonitorEventHandler) (*YakFileMonitor, error)
func (*YakFileMonitor) SetFileTree ¶
func (m *YakFileMonitor) SetFileTree(fileTree *FileNode)
func (*YakFileMonitor) UpdateFileTree ¶
func (m *YakFileMonitor) UpdateFileTree() error
type ZipDirEntry ¶
type ZipDirEntry struct {
// contains filtered or unexported fields
}
func (*ZipDirEntry) IsDir ¶
func (z *ZipDirEntry) IsDir() bool
func (*ZipDirEntry) Name ¶
func (z *ZipDirEntry) Name() string
func (*ZipDirEntry) Type ¶
func (z *ZipDirEntry) Type() fs.FileMode
type ZipFS ¶
type ZipFS struct {
// contains filtered or unexported fields
}
func NewZipFSFromLocal ¶
func NewZipFSFromString ¶
func (*ZipFS) GetSeparators ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.