Documentation ¶
Index ¶
- Constants
- Variables
- func Recursive(raw string, opts ...Option) error
- type Config
- type DirStat
- type Event
- type EventSet
- type FileNode
- type FileStat
- type FileSystem
- type LocalFs
- func (f *LocalFs) GetSeparators() rune
- func (f *LocalFs) Join(name ...string) string
- func (f *LocalFs) Open(name string) (fs.File, error)
- func (f *LocalFs) ReadDir(dirname string) ([]fs.DirEntry, error)
- func (f *LocalFs) ReadFile(name string) ([]byte, error)
- func (f *LocalFs) Stat(name string) (fs.FileInfo, 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 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 VirtualFS
- func (vf *VirtualFS) AddDir(dirName string) *VirtualFile
- func (vs *VirtualFS) AddFile(name, content string)
- func (vs *VirtualFS) GetLocalFSPath() string
- func (vs *VirtualFS) GetSeparators() rune
- func (vs *VirtualFS) Join(name ...string) string
- func (vs *VirtualFS) Open(name string) (fs.File, error)
- func (vs *VirtualFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (vs *VirtualFS) ReadFile(name string) ([]byte, error)
- func (vs *VirtualFS) RemoveFileOrDir(name string) error
- func (vs *VirtualFS) Stat(name string) (fs.FileInfo, 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
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 ¶
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 FileSystem ¶ added in v1.3.3
type FileSystem interface { ReadFile(name string) ([]byte, error) Open(name string) (fs.File, error) // Stat returns a FileInfo describing the file. // If there is an error, it should be of type *PathError. Stat(name string) (fs.FileInfo, error) // RelStat(name string) (fs.FileInfo, error) // ReadDir reads the named directory // and returns a list of directory entries sorted by filename. ReadDir(name string) ([]fs.DirEntry, error) Join(elem ...string) string GetSeparators() rune }
FileSystem defines the methods of an abstract filesystem.
func NewEmbedFS ¶ added in v1.3.3
func NewEmbedFS(fs embed.FS) FileSystem
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 FileSystem) Option
func WithRecursiveDirectory ¶ added in v1.3.3
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 (vf *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
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
Click to show internal directories.
Click to hide internal directories.