avyos.dev/pkg/fs

package fs

Overview

No package-level documentation is provided.

Export GroupCount
Constants0
Variables0
Functions15
Types3

Functions

Copy

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

Copy copies a file or directory from src to dst.

Exists

func Exists(path string) bool

Exists checks if a path exists.

Find

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

Find finds files matching a pattern in a directory.

IsDir

func IsDir(path string) bool

IsDir checks if a path is a directory.

IsFile

func IsFile(path string) bool

IsFile checks if a path is a regular file.

IsSymlink

func IsSymlink(path string) bool

IsSymlink checks if a path is a symbolic link.

MkdirAll

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

MkdirAll creates a directory and all parent directories.

Move

func Move(src, dst string) error

Move moves a file or directory from src to dst.

PermString

func PermString(mode os.FileMode) string

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

ReadLink

func ReadLink(path string) (string, error)

ReadLink returns the destination of a symbolic link.

Remove

func Remove(path string, recursive bool) error

Remove removes a file or directory.

Resolve

func Resolve(format string, args ...any) string

Symlink

func Symlink(target, link string) error

Symlink creates a symbolic link.

Touch

func Touch(path string) error

Touch creates an empty file or updates the modification time.

Walk

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

Info

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

Info returns information about a file.

ListDir

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

Tree

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.