filesys

package
v1.3.3-beta6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Exports = map[string]any{
	"Recursive": Recursive,

	"onReady":    withYaklangOnStart,
	"onStat":     withYaklangStat,
	"onFileStat": withYaklangFileStat,
	"onDirStat":  withYaklangDirStat,
	"dir":        WithDir,
}

Functions

func Recursive

func Recursive(raw string, opts ...Option) error

Recursive recursively walk through the file system raw: the root path opts: options return: error

Example: ``` err := filesys.Recursive( //

"testdata",
filesys.dir(["cc", "dd"], filesys.onFileStat((name, info) => {})),

) ```

Types

type Config

type Config struct {
	RecursiveDirectory bool
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

type DirStat added in v1.3.3

type DirStat func(string, fs.FileInfo) error

type FileStat added in v1.3.3

type FileStat func(string, fs.File, fs.FileInfo) error

type FileSystem added in v1.3.3

type FileSystem interface {
	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)
	// 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 string

local filesystem

func NewLocalFs added in v1.3.3

func NewLocalFs() LocalFs

func NewLocalFsWithPath added in v1.3.3

func NewLocalFsWithPath(path string) LocalFs

func (LocalFs) GetSeparators added in v1.3.3

func (f LocalFs) GetSeparators() rune

func (LocalFs) Join added in v1.3.3

func (f LocalFs) Join(name ...string) string

func (LocalFs) Open added in v1.3.3

func (f LocalFs) Open(name string) (fs.File, error)

func (LocalFs) ReadDir added in v1.3.3

func (f LocalFs) ReadDir(dirname string) ([]fs.DirEntry, error)

func (LocalFs) Stat added in v1.3.3

func (f LocalFs) Stat(name string) (fs.FileInfo, error)

type Option

type Option func(*Config)

func WithDir

func WithDir(globDir string, opts ...Option) Option

func WithDirStat

func WithDirStat(f DirStat) Option

func WithEmbedFS

func WithEmbedFS(f embed.FS) Option

func WithFileStat

func WithFileStat(f FileStat) Option

func WithFileSystem

func WithFileSystem(f FileSystem) Option

func WithOnStart

func WithOnStart(f func(basename string, isDir bool) error) Option

func WithRecursiveDirectory added in v1.3.3

func WithRecursiveDirectory(b bool) Option

func WithStat

func WithStat(f func(isDir bool, pathname string, info os.FileInfo) error) Option

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) AddFile added in v1.3.3

func (vs *VirtualFS) AddFile(name, content string)

func (*VirtualFS) GetSeparators added in v1.3.3

func (vs *VirtualFS) GetSeparators() rune

func (*VirtualFS) Join added in v1.3.3

func (vs *VirtualFS) Join(name ...string) string

func (*VirtualFS) Open added in v1.3.3

func (vs *VirtualFS) Open(name string) (fs.File, error)

func (*VirtualFS) ReadDir added in v1.3.3

func (vs *VirtualFS) ReadDir(name string) ([]fs.DirEntry, error)

func (*VirtualFS) RemoveFileOrDir added in v1.3.3

func (vs *VirtualFS) RemoveFileOrDir(name string) error

func (*VirtualFS) Stat added in v1.3.3

func (vs *VirtualFS) Stat(name string) (fs.FileInfo, error)

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) Read added in v1.3.3

func (vf *VirtualFile) Read(p []byte) (int, error)

func (*VirtualFile) Stat added in v1.3.3

func (vf *VirtualFile) Stat() (fs.FileInfo, 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL