vfs

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTemp

func CreateTemp(dir, pattern string) (*os.File, error)

func Getwd

func Getwd() (string, error)

func Lstat

func Lstat(name string) (fs.FileInfo, error)

func MkdirAll

func MkdirAll(path string, perm fs.FileMode) error

func Open

func Open(name string) (*os.File, error)

func OpenFile

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

func ReadDir

func ReadDir(name string) ([]os.DirEntry, error)

func ReadFile

func ReadFile(name string) ([]byte, error)

func Remove

func Remove(name string) error

func Rename

func Rename(oldpath, newpath string) error

func Stat

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

func UserHomeDir

func UserHomeDir() (string, error)

func WriteFile

func WriteFile(name string, data []byte, perm fs.FileMode) error

Types

type FS

type FS interface {
	// Query
	Stat(name string) (fs.FileInfo, error)
	Lstat(name string) (fs.FileInfo, error)
	Getwd() (string, error)
	UserHomeDir() (string, error)

	// Read/Write
	ReadFile(name string) ([]byte, error)
	WriteFile(name string, data []byte, perm fs.FileMode) error
	Open(name string) (*os.File, error)
	OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
	CreateTemp(dir, pattern string) (*os.File, error)

	// Directory/File management
	MkdirAll(path string, perm fs.FileMode) error
	ReadDir(name string) ([]os.DirEntry, error)
	Remove(name string) error
	Rename(oldpath, newpath string) error
}

FS abstracts filesystem operations used across the project. Implementations must behave identically to the corresponding os package functions.

var DefaultFS FS = OsFs{}

DefaultFS is the global filesystem instance used by business code. It points to the real OS implementation; tests may replace it with a mock.

type OsFs

type OsFs struct{}

OsFs delegates every method to the os standard library.

func (OsFs) CreateTemp

func (OsFs) CreateTemp(dir, pattern string) (*os.File, error)

func (OsFs) Getwd

func (OsFs) Getwd() (string, error)

func (OsFs) Lstat

func (OsFs) Lstat(name string) (fs.FileInfo, error)

func (OsFs) MkdirAll

func (OsFs) MkdirAll(path string, perm fs.FileMode) error

Directory/File management

func (OsFs) Open

func (OsFs) Open(name string) (*os.File, error)

func (OsFs) OpenFile

func (OsFs) OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)

func (OsFs) ReadDir

func (OsFs) ReadDir(name string) ([]os.DirEntry, error)

func (OsFs) ReadFile

func (OsFs) ReadFile(name string) ([]byte, error)

Read/Write

func (OsFs) Remove

func (OsFs) Remove(name string) error

func (OsFs) Rename

func (OsFs) Rename(oldpath, newpath string) error

func (OsFs) Stat

func (OsFs) Stat(name string) (fs.FileInfo, error)

Query

func (OsFs) UserHomeDir

func (OsFs) UserHomeDir() (string, error)

func (OsFs) WriteFile

func (OsFs) WriteFile(name string, data []byte, perm fs.FileMode) error

Jump to

Keyboard shortcuts

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