Documentation
¶
Index ¶
- Constants
- Variables
- func Copy(destFS, srcFS filesys_interface.FileSystem) (int, error)
- func CreateEmbedFSHash(f embed.FS, opts ...Option) (string, error)
- func DumpTreeView(f fi.FileSystem) string
- func DumpTreeViewWithLimits(f fi.FileSystem, maxDepth, maxLines int) string
- func Glance(localfile any) string
- func NewArchiveFSFromLocal(archivePath string) (fi.FileSystem, error)
- func NewEmbedFS(fs embed.FS) fi.FileSystem
- func Peephole(f fi.FileSystem, opts ...PeepholeConfigOption) error
- func Recursive(raw string, opts ...Option) error
- func SerializeFileSystemToGzipBytes(fsys fi.FileSystem, opts ...GzipSerializeOption) ([]byte, error)
- func SimpleRecursive(opts ...Option) error
- func SplitWithSeparator(path string, sep rune) (string, string)
- func TreeView(f fi.FileSystem)
- func WithUnifiedFsExtMap(extReal, extVirtual string) func(config *UnifiedFSConfig)
- func WithUnifiedFsSeparator(sep rune) func(config *UnifiedFSConfig)
- type Config
- type DirStat
- type Event
- type EventSet
- type FileNode
- type FileStat
- type GzipFS
- type GzipSerializeOption
- type HookAfterFunc
- type HookBeforeFunc
- type HookFS
- func (f *HookFS) AddReadHook(hook *ReadHook)
- func (f *HookFS) Base(p string) string
- func (f *HookFS) Delete(name string) error
- func (f *HookFS) Exists(path string) (bool, error)
- func (f *HookFS) Ext(s string) string
- func (f *HookFS) ExtraInfo(path string) map[string]any
- func (f *HookFS) GetSeparators() rune
- func (f *HookFS) Getwd() (string, error)
- func (f *HookFS) IsAbs(name string) bool
- func (f *HookFS) Join(paths ...string) string
- func (f *HookFS) MkdirAll(name string, perm os.FileMode) error
- func (f *HookFS) Open(name string) (fs.File, error)
- func (f *HookFS) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error)
- func (f *HookFS) PathSplit(s string) (string, string)
- func (f *HookFS) ReadDir(dirname string) ([]fs.DirEntry, error)
- func (f *HookFS) ReadFile(name string) ([]byte, error)
- func (f *HookFS) Rel(base string, target string) (string, error)
- func (f *HookFS) Rename(old string, new string) error
- func (f *HookFS) Root() string
- func (f *HookFS) SetEnabled(enabled bool)
- func (f *HookFS) Stat(name string) (fs.FileInfo, error)
- func (f *HookFS) String() string
- func (f *HookFS) WriteFile(name string, data []byte, perm os.FileMode) error
- type HookMatcher
- type HookMatcherFunc
- type LocalFs
- func (f *LocalFs) Base(p string) string
- 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) ExtraInfo(string) map[string]any
- 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) String() string
- func (f *LocalFs) Throw(filenames ...string) error
- func (f *LocalFs) WriteFile(name string, data []byte, perm os.FileMode) error
- type MonitorEventHandler
- type Option
- func WithContext(ctx context.Context) 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 WithExcludeExts(exts ...string) Option
- func WithFileLimit(limit int) Option
- func WithFileStat(f FileStat) Option
- func WithFileSystem(f fi.FileSystem) Option
- func WithIncludeExts(exts ...string) 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 PeepholeConfig
- type PeepholeConfigOption
- type PeepholeTrigger
- type ReadHook
- type ReadHookContext
- type RelLocalFs
- func (f *RelLocalFs) Base(p string) string
- 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) ExtraInfo(string) map[string]any
- 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) Root() string
- 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 UnifiedDirEntry
- type UnifiedFS
- func (u *UnifiedFS) Base(name string) string
- func (u *UnifiedFS) Delete(name string) error
- func (u *UnifiedFS) Exists(name string) (bool, error)
- func (u *UnifiedFS) Ext(name string) string
- func (u *UnifiedFS) ExtraInfo(s string) map[string]any
- func (u *UnifiedFS) GetFileSystem() fi.FileSystem
- func (u *UnifiedFS) GetSeparators() rune
- func (u *UnifiedFS) Getwd() (string, error)
- func (u *UnifiedFS) IsAbs(name string) bool
- func (u *UnifiedFS) Join(elem ...string) string
- func (u *UnifiedFS) MkdirAll(name string, perm os.FileMode) error
- func (u *UnifiedFS) Open(name string) (fs.File, error)
- func (u *UnifiedFS) OpenFile(name string, flag int, perm os.FileMode) (fs.File, error)
- func (u *UnifiedFS) PathSplit(name string) (string, string)
- func (u *UnifiedFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (u *UnifiedFS) ReadFile(name string) ([]byte, error)
- func (u *UnifiedFS) Rel(s string, s2 string) (string, error)
- func (u *UnifiedFS) Rename(old string, new string) error
- func (u *UnifiedFS) Stat(name string) (fs.FileInfo, error)
- func (f *UnifiedFS) String() string
- func (u *UnifiedFS) WriteFile(name string, data []byte, perm os.FileMode) error
- type UnifiedFSConfig
- type UnifiedFile
- type UnifiedFileInfo
- type UnifiedFsOption
- type VirtualFS
- func (f *VirtualFS) AddDir(dirName string) *VirtualFile
- func (f *VirtualFS) AddFile(name, content string)
- func (f *VirtualFS) Base(s string) 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) ExtraInfo(string) map[string]any
- 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) String() string
- 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 WatchPathOption
- type YakFileMonitor
- type ZipDirEntry
- type ZipFS
- func NewZipFSFromLocal(i string) (*ZipFS, error)
- func NewZipFSFromLocalWithOptions(i string, opts ...ZipFSOption) (*ZipFS, error)
- func NewZipFSFromString(i string) (*ZipFS, error)
- func NewZipFSFromStringWithOptions(i string, opts ...ZipFSOption) (*ZipFS, error)
- func NewZipFSRaw(i io.ReaderAt, size int64) (*ZipFS, error)
- func NewZipFSRawWithCloser(i io.ReaderAt, size int64, closer io.Closer) (*ZipFS, error)
- func NewZipFSRawWithCloserAndOptions(i io.ReaderAt, size int64, closer io.Closer, opts ...ZipFSOption) (*ZipFS, error)
- func NewZipFSRawWithOptions(i io.ReaderAt, size int64, opts ...ZipFSOption) (*ZipFS, error)
- func (f *ZipFS) Base(p string) string
- func (z *ZipFS) Clean(name string) string
- func (z *ZipFS) Close() error
- func (z *ZipFS) Delete(s string) error
- func (z *ZipFS) Exists(s string) (bool, error)
- func (z *ZipFS) Ext(i string) string
- func (f *ZipFS) ExtraInfo(string) map[string]any
- 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) SetPassword(password string) *ZipFS
- func (z *ZipFS) Stat(name string) (fs.FileInfo, error)
- func (f *ZipFS) String() string
- func (z *ZipFS) WriteFile(s string, bytes []byte, mode os.FileMode) error
- type ZipFSOption
Constants ¶
const ( FsMonitorCreate = "create" // dir FsMonitorWrite = "write" FsMonitorRename = "rename" FsMonitorRemove = "remove" FsMonitorChmod = "chmod" FsMonitorChange = "change" FsMonitorTouch = "touch" FsMonitorDelete = "delete" )
Variables ¶
var ErrNoFileFound = errors.New("no file found")
ErrNoFileFound is returned when CreateEmbedFSHash finds no files to process
var Exports = map[string]any{ "CopyToTemporary": CopyToTemporary, "CopyToRefLocal": CopyToRefLocal, "Recursive": Recursive, "Glance": Glance, "onFS": withYaklangFileSystem, "onReady": withYaklangOnStart, "onStat": withYaklangStat, "onStatEx": withYaklangStatEx, "onFileStat": withYaklangFileStat, "onFileStatEx": withYaklangFileStatEx, "onDirStat": withYaklangDirStat, "dir": WithDir, }
var SkipAll = errors.New("skip all")
var SkipDir = errors.New("skip dir")
Functions ¶
func Copy ¶
func Copy(destFS, srcFS filesys_interface.FileSystem) (int, error)
func DumpTreeView ¶
func DumpTreeView(f fi.FileSystem) string
func DumpTreeViewWithLimits ¶
func DumpTreeViewWithLimits(f fi.FileSystem, maxDepth, maxLines int) string
func Glance ¶
Glance 快速查看一个文件系统或本地目录的概览信息(统计与树形结构) 参数:
- localfile: 本地目录路径,或一个 FileSystem 对象
返回值:
- 包含目录统计与树形视图的概览字符串
Example: ``` // 在临时目录创建文件后查看概览,输出应包含统计信息 root = file.Join(os.TempDir(), "yak-filesys-glance") file.MkdirAll(root) file.Save(file.Join(root, "a.txt"), "A")~ summary = filesys.Glance(root) assert str.Contains(summary, "total:"), "Glance output should contain a total summary" file.Remove(root) ```
func NewArchiveFSFromLocal ¶
func NewArchiveFSFromLocal(archivePath string) (fi.FileSystem, error)
NewArchiveFSFromLocal creates a read-only filesystem from a local archive file. Supported archive formats are zip, tar, tar.gz and tgz.
func NewEmbedFS ¶
func NewEmbedFS(fs embed.FS) fi.FileSystem
func Peephole ¶
func Peephole(f fi.FileSystem, opts ...PeepholeConfigOption) error
func Recursive ¶
Recursive 递归遍历指定路径下的所有文件和目录,对每个条目按配置的回调进行处理 参数:
- raw: 起始遍历的根路径
- opts: 遍历选项(如 filesys.onFileStat、filesys.onDirStat、filesys.dir 等)
返回值:
- 错误信息
Example: ``` // 在临时目录创建两个文件,递归统计文件数量 root = file.Join(os.TempDir(), "yak-filesys-recursive") file.MkdirAll(root) file.Save(file.Join(root, "a.txt"), "A")~ file.Save(file.Join(root, "b.txt"), "B")~ count = 0 filesys.Recursive(root, filesys.onFileStat((name, info) => { count++ }))~ assert count == 2, "Recursive should visit both files" file.Remove(root) ```
func SerializeFileSystemToGzipBytes ¶
func SerializeFileSystemToGzipBytes(fsys fi.FileSystem, opts ...GzipSerializeOption) ([]byte, error)
SerializeFileSystemToGzipBytes serializes a filesystem into tar.gz bytes.
func SimpleRecursive ¶
func TreeView ¶
func TreeView(f fi.FileSystem)
func WithUnifiedFsExtMap ¶
func WithUnifiedFsExtMap(extReal, extVirtual string) func(config *UnifiedFSConfig)
func WithUnifiedFsSeparator ¶
func WithUnifiedFsSeparator(sep rune) func(config *UnifiedFSConfig)
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 GzipFS ¶
type GzipFS struct {
*VirtualFS
// contains filtered or unexported fields
}
GzipFS is a runtime tar.gz-backed filesystem materialized into a VirtualFS. It is primarily used to persist and restore small embedded file trees.
func NewGzipFSFromBytes ¶
NewGzipFSFromBytes restores a tar.gz-encoded filesystem into a VirtualFS-backed FS.
type GzipSerializeOption ¶
type GzipSerializeOption func(*gzipSerializeConfig)
func WithGzipFSExcludePaths ¶
func WithGzipFSExcludePaths(paths ...string) GzipSerializeOption
WithGzipFSExcludePaths excludes specific paths from serialized tar.gz output.
type HookAfterFunc ¶
type HookAfterFunc func(ctx *ReadHookContext, data []byte) ([]byte, error)
type HookBeforeFunc ¶
type HookBeforeFunc func(ctx *ReadHookContext) error
type HookFS ¶
type HookFS struct {
// contains filtered or unexported fields
}
func (*HookFS) AddReadHook ¶
AddReadHook 注册一个 read hook。
func (*HookFS) GetSeparators ¶
type HookMatcher ¶
func SuffixMatcher ¶
func SuffixMatcher(suffixes ...string) HookMatcher
SuffixMatcher 根据后缀匹配文件名,不区分大小写。
type HookMatcherFunc ¶
func (HookMatcherFunc) Match ¶
func (f HookMatcherFunc) Match(name string) bool
type LocalFs ¶
type LocalFs struct {
// contains filtered or unexported fields
}
local FileSystem
func NewLocalFs ¶
func NewLocalFs() *LocalFs
func (*LocalFs) GetSeparators ¶
type MonitorEventHandler ¶
type MonitorEventHandler func(events *EventSet)
type Option ¶
type Option func(*Config)
func WithContext ¶
func WithDir ¶
dir 为匹配指定 glob 目录的子树设置一组单独的遍历选项 参数:
- globDir: 目录匹配的 glob 模式
- opts: 对匹配到的子目录生效的遍历选项
返回值:
- 一个遍历配置选项
Example: ``` filesys.Recursive("testdata", filesys.dir("cc", filesys.onFileStat((name, info) => {})))~ ```
func WithDirStat ¶
func WithDirWalkEnd ¶
func WithEmbedFS ¶
func WithExcludeExts ¶
WithExcludeExts sets file extensions to exclude (files with these extensions will be skipped) The filtering is handled in Recursive function before calling onFileStat. Example: WithExcludeExts(".tmp", ".bak")
func WithFileLimit ¶
func WithFileStat ¶
func WithFileSystem ¶
func WithFileSystem(f fi.FileSystem) Option
func WithIncludeExts ¶
WithIncludeExts sets file extensions to include (only files with these extensions will be processed) The filtering is handled in Recursive function before calling onFileStat. Example: WithIncludeExts(".yak", ".fs")
func WithRecursiveDirectory ¶
type PeepholeConfig ¶
type PeepholeConfig struct {
// peephole handler
Size int
Callback func(count, total int, f fi.FileSystem)
// contains filtered or unexported fields
}
func (*PeepholeConfig) CallbackFS ¶
func (c *PeepholeConfig) CallbackFS(f fi.FileSystem, triggers *utils.SafeMap[*PeepholeTrigger])
type PeepholeConfigOption ¶
type PeepholeConfigOption func(*PeepholeConfig) error
func WithPeepholeCallback ¶
func WithPeepholeCallback(i func(int, int, fi.FileSystem)) PeepholeConfigOption
func WithPeepholeContext ¶
func WithPeepholeContext(ctx context.Context) PeepholeConfigOption
func WithPeepholeSize ¶
func WithPeepholeSize(i int) PeepholeConfigOption
type PeepholeTrigger ¶
type ReadHook ¶
type ReadHook struct {
Matcher HookMatcher
BeforeRead HookBeforeFunc
AfterRead HookAfterFunc
}
type ReadHookContext ¶
type ReadHookContext struct {
Name string
FS fi.FileSystem
Underlying fi.FileSystem
}
type RelLocalFs ¶
type RelLocalFs struct {
// contains filtered or unexported fields
}
func CopyToRefLocal ¶
func CopyToRefLocal(srcFs filesys_interface.FileSystem, dest string) (*RelLocalFs, error)
CopyToRefLocal 把一个源文件系统的全部内容拷贝到指定的本地目录,并返回指向该目录的文件系统对象 参数:
- srcFs: 源文件系统对象
- dest: 目标本地目录路径(不存在时会自动创建)
返回值:
- 指向目标本地目录的文件系统对象
- 错误信息
Example: ``` // 将一个内存 zip 文件系统拷贝到本地目录 zfs = filesys.NewZipFSFromLocal("/tmp/abc.zip")~ localFs = filesys.CopyToRefLocal(zfs, "/tmp/abc_extracted")~ ```
func CopyToTemporary ¶
func CopyToTemporary(srcFs filesys_interface.FileSystem) *RelLocalFs
CopyToTemporary 把一个源文件系统的全部内容拷贝到一个新建的临时目录,并返回指向该临时目录的文件系统对象 参数:
- srcFs: 源文件系统对象
返回值:
- 指向新建临时目录的文件系统对象
Example: ``` // 将一个内存 zip 文件系统拷贝到临时目录 zfs = filesys.NewZipFSFromLocal("/tmp/abc.zip")~ tmpFs = filesys.CopyToTemporary(zfs) ```
func NewRelLocalFs ¶
func NewRelLocalFs(rel string) *RelLocalFs
func (*RelLocalFs) Base ¶
func (f *RelLocalFs) Base(p string) string
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) Root ¶
func (f *RelLocalFs) Root() string
func (*RelLocalFs) String ¶
func (f *RelLocalFs) String() string
type UnifiedDirEntry ¶
func (*UnifiedDirEntry) Name ¶
func (e *UnifiedDirEntry) Name() string
type UnifiedFS ¶
type UnifiedFS struct {
// contains filtered or unexported fields
}
func NewUnifiedFS ¶
func NewUnifiedFS(fs fi.FileSystem, opts ...UnifiedFsOption) *UnifiedFS
func (*UnifiedFS) GetFileSystem ¶
func (u *UnifiedFS) GetFileSystem() fi.FileSystem
func (*UnifiedFS) GetSeparators ¶
type UnifiedFSConfig ¶
type UnifiedFSConfig struct {
Separator rune
// contains filtered or unexported fields
}
type UnifiedFile ¶
func (*UnifiedFile) Name ¶
func (f *UnifiedFile) Name() string
type UnifiedFileInfo ¶
func (*UnifiedFileInfo) IsDir ¶
func (i *UnifiedFileInfo) IsDir() bool
func (*UnifiedFileInfo) Name ¶
func (i *UnifiedFileInfo) Name() string
type UnifiedFsOption ¶
type UnifiedFsOption func(config *UnifiedFSConfig)
type VirtualFS ¶
type VirtualFS struct {
// contains filtered or unexported fields
}
func NewTarFSFromBytes ¶
NewTarFSFromBytes restores a tar-encoded filesystem into a VirtualFS-backed FS.
func NewVirtualFs ¶
func NewVirtualFs() *VirtualFS
func (*VirtualFS) AddDir ¶
func (f *VirtualFS) AddDir(dirName string) *VirtualFile
func (*VirtualFS) GetLocalFSPath ¶
func (*VirtualFS) GetSeparators ¶
func (*VirtualFS) RemoveFileOrDir ¶
type VirtualFile ¶
type VirtualFile struct {
// contains filtered or unexported fields
}
func NewVirtualFile ¶
func NewVirtualFile(name string, content string) *VirtualFile
func NewVirtualFileDirectory ¶
func NewVirtualFileDirectory(dirName string, dir *VirtualFS) *VirtualFile
func (*VirtualFile) Close ¶
func (vf *VirtualFile) Close() error
func (*VirtualFile) FS ¶
func (f *VirtualFile) FS() fi.FileSystem
type VirtualFileInfo ¶
type VirtualFileInfo struct {
// contains filtered or unexported fields
}
func NewVirtualFileInfo ¶
func NewVirtualFileInfo(name string, size int64, isDir bool) *VirtualFileInfo
func (*VirtualFileInfo) IsDir ¶
func (vi *VirtualFileInfo) IsDir() bool
func (*VirtualFileInfo) ModTime ¶
func (vi *VirtualFileInfo) ModTime() time.Time
func (*VirtualFileInfo) Mode ¶
func (vi *VirtualFileInfo) Mode() os.FileMode
func (*VirtualFileInfo) Name ¶
func (vi *VirtualFileInfo) Name() string
func (*VirtualFileInfo) Size ¶
func (vi *VirtualFileInfo) Size() int64
func (*VirtualFileInfo) Sys ¶
func (vi *VirtualFileInfo) Sys() any
func (*VirtualFileInfo) Type ¶
func (vi *VirtualFileInfo) Type() fs.FileMode
type WatchPathOption ¶
type WatchPathOption func(*watchPathConfig)
func WithPollInterval ¶
func WithPollInterval(interval time.Duration) WatchPathOption
type YakFileMonitor ¶
type YakFileMonitor struct {
Events chan *EventSet
RecursiveFinish chan struct{} // recursive finish
FileTreeMutex sync.Mutex
FileTree *FileNode
WatchPatch string
PollInterval time.Duration
Ctx context.Context
CancelFunc context.CancelFunc
}
func WatchPath ¶
func WatchPath(ctx context.Context, path string, eventHandler MonitorEventHandler, opts ...WatchPathOption) (*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 NewZipFSFromLocalWithOptions ¶
func NewZipFSFromLocalWithOptions(i string, opts ...ZipFSOption) (*ZipFS, error)
NewZipFSFromLocalWithOptions 从本地文件构造带密码 ZipFS 关键词: ZipFS 密码构造, NewZipFSFromLocalWithOptions
func NewZipFSFromString ¶
func NewZipFSFromStringWithOptions ¶
func NewZipFSFromStringWithOptions(i string, opts ...ZipFSOption) (*ZipFS, error)
NewZipFSFromStringWithOptions 从字符串/字节构造带密码 ZipFS 关键词: ZipFS 密码构造, NewZipFSFromStringWithOptions
func NewZipFSRawWithCloser ¶
NewZipFSRawWithCloser 创建一个 ZipFS,并保存一个可选的 closer 用于关闭文件句柄
func NewZipFSRawWithCloserAndOptions ¶
func NewZipFSRawWithCloserAndOptions(i io.ReaderAt, size int64, closer io.Closer, opts ...ZipFSOption) (*ZipFS, error)
NewZipFSRawWithCloserAndOptions 同 NewZipFSRawWithCloser,但接受 ZipFSOption 关键词: ZipFS 密码构造, NewZipFSRawWithCloserAndOptions
func NewZipFSRawWithOptions ¶
NewZipFSRawWithOptions 创建带选项(含密码)的 ZipFS 关键词: ZipFS 密码构造, NewZipFSRawWithOptions
func (*ZipFS) GetSeparators ¶
func (*ZipFS) SetPassword ¶
SetPassword 后置设置 ZipFS 解密密码 关键词: ZipFS 密码运行时设置
type ZipFSOption ¶
type ZipFSOption func(*zipFSConfig)
ZipFSOption 用于 NewZipFS*WithOptions 的可选参数 关键词: ZipFS 选项, ZipFS 密码
func WithZipFSPassword ¶
func WithZipFSPassword(password string) ZipFSOption
WithZipFSPassword 设置加密 zip 的解密密码 关键词: ZipFS 密码, 加密 zip 文件系统