fsh

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDirPerm = 0o755

Variables

This section is empty.

Functions

func Abs added in v0.29.0

func Abs(fSys FS, path string) (string, error)

func DirSize added in v0.30.0

func DirSize(fSys FS, path string) (int64, error)

func ExpandTilde added in v0.29.0

func ExpandTilde(fs FS, path string) (string, error)

func Ext added in v0.37.0

func Ext(filename string) string

Ext works like filepath.Ext but supports .tar.gz extensions.

func FirstDir added in v0.37.0

func FirstDir(fSys FS, dir string) (string, error)

FirstDir returns first directory name in given directory.

func IsExists

func IsExists(fSys FS, path string) bool

func ReadJson

func ReadJson[T any](ctx context.Context, fs FS, path string) (*T, error)

func ReadOrCreateJson

func ReadOrCreateJson[T any](ctx context.Context, fs FS, path string, defaultVal T) (*T, error)

func SetExecutable added in v0.37.0

func SetExecutable(fSys FS, path string) error

SetExecutable mark file as executable.

func WriteJson

func WriteJson(ctx context.Context, fs FS, in any, path string) error

Types

type FS

type FS interface {
	afero.Fs
	afero.Linker
	GetCurrentDir() string
	GetHomeDir() (string, error)
	Walk(root string, fn filepath.WalkFunc) error
	RLock(ctx context.Context, filename string) (func(), error)
	Lock(ctx context.Context, filename string) (func(), error)
}

func NewRealFS

func NewRealFS() FS

type MemFS

type MemFS struct {
	afero.Fs
	// contains filtered or unexported fields
}

func NewMemFS

func NewMemFS(files map[string]string) *MemFS

func (*MemFS) GetCurrentDir added in v0.29.0

func (m *MemFS) GetCurrentDir() string

func (*MemFS) GetHomeDir added in v0.29.0

func (m *MemFS) GetHomeDir() (string, error)

func (*MemFS) GetTree

func (m *MemFS) GetTree(dir string) ([]string, error)

func (*MemFS) Lock added in v0.34.0

func (m *MemFS) Lock(_ context.Context, _ string) (func(), error)

func (*MemFS) RLock added in v0.34.0

func (m *MemFS) RLock(_ context.Context, _ string) (func(), error)

func (*MemFS) SymlinkIfPossible

func (m *MemFS) SymlinkIfPossible(oldname, newname string) error

func (*MemFS) Walk added in v0.30.0

func (m *MemFS) Walk(root string, fn filepath.WalkFunc) error

type RealFs added in v0.29.0

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

func (*RealFs) Chmod added in v0.29.0

func (r *RealFs) Chmod(name string, mode os.FileMode) error

func (*RealFs) Chown added in v0.29.0

func (r *RealFs) Chown(name string, uid, gid int) error

func (*RealFs) Chtimes added in v0.29.0

func (r *RealFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*RealFs) Create added in v0.29.0

func (r *RealFs) Create(name string) (afero.File, error)

func (*RealFs) GetCurrentDir added in v0.29.0

func (r *RealFs) GetCurrentDir() string

func (*RealFs) GetHomeDir added in v0.29.0

func (r *RealFs) GetHomeDir() (string, error)

func (*RealFs) Lock added in v0.34.0

func (r *RealFs) Lock(ctx context.Context, filename string) (func(), error)

func (*RealFs) Mkdir added in v0.29.0

func (r *RealFs) Mkdir(name string, perm os.FileMode) error

func (*RealFs) MkdirAll added in v0.29.0

func (r *RealFs) MkdirAll(path string, perm os.FileMode) error

func (*RealFs) Name added in v0.29.0

func (r *RealFs) Name() string

func (*RealFs) Open added in v0.29.0

func (r *RealFs) Open(name string) (afero.File, error)

func (*RealFs) OpenFile added in v0.29.0

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

func (*RealFs) RLock added in v0.34.0

func (r *RealFs) RLock(ctx context.Context, filename string) (func(), error)

func (*RealFs) Remove added in v0.29.0

func (r *RealFs) Remove(name string) error

func (*RealFs) RemoveAll added in v0.29.0

func (r *RealFs) RemoveAll(path string) error

func (*RealFs) Rename added in v0.29.0

func (r *RealFs) Rename(oldname, newname string) error

func (*RealFs) Stat added in v0.29.0

func (r *RealFs) Stat(name string) (os.FileInfo, error)

func (*RealFs) SymlinkIfPossible added in v0.29.0

func (r *RealFs) SymlinkIfPossible(oldname, newname string) error

func (*RealFs) Walk added in v0.30.0

func (r *RealFs) Walk(root string, fn filepath.WalkFunc) error

Jump to

Keyboard shortcuts

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