avyos.dev/pkg/fs

package fs

Package Overview

No package-level documentation is provided.

Export GroupCount
Constants1
Variables0
Functions15
Types3

Constants

const (
	AvyosPath     = "/avyos"
	CommandsPath  = "/cmd"
	ServicesPath  = "/services"
	CachePath     = "/cache"
	KernelPath    = "/cache/kernel"
	DevicesPath   = "/cache/kernel/devices"
	ProcessesPath = "/cache/kernel/processes"
	SysfsPath     = "/cache/kernel/sysfs"
	RuntimePath   = "/cache/runtime"
	UserRunPath   = "/cache/runtime/user"
	ConfigPath    = "/config"
	UsersHomePath = "/users"
)

Functions

func Copy(src, dst string, recursive bool) error

Copy copies a file or directory from src to dst.

func Exists(path string) bool

Exists checks if a path exists.

func Find(root, pattern string) ([]string, error)

Find finds files matching a pattern in a directory.

func IsDir(path string) bool

IsDir checks if a path is a directory.

func IsFile(path string) bool

IsFile checks if a path is a regular file.

func IsSymlink(path string) bool

IsSymlink checks if a path is a symbolic link.

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

MkdirAll creates a directory and all parent directories.

func Move(src, dst string) error

Move moves a file or directory from src to dst.

func PermString(mode os.FileMode) string

PermString returns a human-readable permission string (like ls -l).

func ReadLink(path string) (string, error)

ReadLink returns the destination of a symbolic link.

func Remove(path string, recursive bool) error

Remove removes a file or directory.

func Resolve(kind string, p ...string) string
func Symlink(target, link string) error

Symlink creates a symbolic link.

func Touch(path string) error

Touch creates an empty file or updates the modification time.

func Walk(root string, walkFn WalkFunc) error

Walk walks the file tree rooted at root.

Types

FileInfo

type FileInfo struct {
	Name    string
	Path    string
	Size    int64
	Mode    os.FileMode
	ModTime int64 // Unix timestamp
	UID     uint32
	GID     uint32
	IsDir   bool
	IsLink  bool
	Target  string // For symlinks
}

FileInfo represents information about a file.

Functions

func Info(path string) (*FileInfo, error)

Info returns information about a file.

func ListDir(path string) ([]*FileInfo, error)

ListDir lists the contents of a directory.

TreeEntry

type TreeEntry struct {
	Info     *FileInfo
	Children []*TreeEntry
	Depth    int
}

TreeEntry represents an entry in a directory tree.

Functions

func Tree(path string, maxDepth int) (*TreeEntry, error)

Tree builds a directory tree.

WalkFunc

type WalkFunc func(path string, info os.FileInfo, err error) error

Walk walks a directory tree, calling walkFn for each file or directory.