vfs

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(pattern string, path string, o *SearchOptions) (string, error)

Types

type FileInfo

type FileInfo struct {
	Filename string `json:"filename"`

	IsDirectory bool `json:"isDirectory"`
	IsFile      bool `json:"isFile"`
	IsLink      bool `json:"isLink"`

	Permissions string `json:"permissions"`

	Length   int64     `json:"size"`
	Created  time.Time `json:"created"`
	Modified time.Time `json:"modified"`
	Accessed time.Time `json:"accessed"`

	// original info for local fs
	Info fs.FileInfo `json:"-"`
}

func (*FileInfo) IsDir

func (r *FileInfo) IsDir() bool

abbreviation for Mode().IsDir()

func (*FileInfo) ModTime

func (r *FileInfo) ModTime() time.Time

modification time

func (*FileInfo) Mode

func (r *FileInfo) Mode() fs.FileMode

file mode bits

func (*FileInfo) Name

func (r *FileInfo) Name() string

base name of the file

func (*FileInfo) Size

func (r *FileInfo) Size() int64

length in bytes for regular files; system-dependent for others

func (*FileInfo) String

func (f *FileInfo) String() string

func (*FileInfo) Sys

func (r *FileInfo) Sys() any

underlying data source (can return nil)

type FileStat

type FileStat interface {
	Lstat(name string) (fs.FileInfo, error)
	Stat(name string) (fs.FileInfo, error)
}

type FileStore

type FileStore interface {
	ReadFile(string) ([]byte, error)
	WriteFile(string, []byte) error

	// aka:
	// absolute path for file, endpoint for rest, and url for web
	Locator(string) (string, error)
}

type FileSystem

type FileSystem interface {
	FileStore

	ListDirectory(string) ([]string, error)
	CreateDirectory(string) error
	RenameFile(string, string) error
	FileInfo(string) (*FileInfo, error)
	// EditFile
	SearchFiles(pattern string, path string, options *SearchOptions) (string, error)
}

FileSystem is a virtual file system that provides a set of operations to interact with the file system in a controlled manner.

type LocalFS

type LocalFS struct {
	// contains filtered or unexported fields
}

Local fs is a workspace

func (*LocalFS) CreateDirectory

func (s *LocalFS) CreateDirectory(path string) error

func (*LocalFS) FileInfo

func (s *LocalFS) FileInfo(path string) (*FileInfo, error)

func (*LocalFS) ListDirectory

func (s *LocalFS) ListDirectory(path string) ([]string, error)

func (*LocalFS) Locator

func (s *LocalFS) Locator(path string) (string, error)

func (*LocalFS) Lstat

func (s *LocalFS) Lstat(path string) (fs.FileInfo, error)

func (*LocalFS) OpenFile

func (s *LocalFS) OpenFile(path string, flag int, perm fs.FileMode) (*os.File, error)

func (*LocalFS) ReadDir

func (s *LocalFS) ReadDir(path string) ([]fs.DirEntry, error)

func (*LocalFS) ReadFile

func (s *LocalFS) ReadFile(path string) ([]byte, error)

func (*LocalFS) RenameFile

func (s *LocalFS) RenameFile(source, destination string) error

func (*LocalFS) SearchFiles

func (s *LocalFS) SearchFiles(pattern string, path string, options *SearchOptions) (string, error)

func (*LocalFS) Stat

func (s *LocalFS) Stat(path string) (fs.FileInfo, error)

func (*LocalFS) WriteFile

func (s *LocalFS) WriteFile(path string, content []byte) error

type SearchOptions

type SearchOptions struct {
	// Parse PATTERN as a regular expression
	// Accepted syntax is the same
	// as https://github.com/google/re2/wiki/Syntax
	Regexp bool
	// Match case insensitively
	IgnoreCase bool
	// Only match whole words
	WordRegexp bool
	// Ignore files/directories matching pattern
	Exclude []string
	// Limit search to filenames matching PATTERN
	FileSearchRegexp string
	// Search up to 'Depth' directories deep (default: 25)
	Depth int
	// Follow symlinks
	Follow bool
	// Search hidden files and directories
	Hidden bool
}

type Workspace

type Workspace interface {
	FileSystem

	OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
	ReadDir(name string) ([]fs.DirEntry, error)
}

func NewLocalFS

func NewLocalFS(root string) Workspace

Jump to

Keyboard shortcuts

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