avyos.dev/pkg/fs
package fs
Overview
No package-level documentation is provided.
| Export Group | Count |
|---|---|
| Constants | 0 |
| Variables | 0 |
| Functions | 15 |
| Types | 3 |
Functions
Copy
func Copy(src, dst string, recursive bool) errorCopy copies a file or directory from src to dst.
Exists
func Exists(path string) boolExists 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) boolIsDir checks if a path is a directory.
IsFile
func IsFile(path string) boolIsFile checks if a path is a regular file.
IsSymlink
func IsSymlink(path string) boolIsSymlink checks if a path is a symbolic link.
MkdirAll
func MkdirAll(path string, perm os.FileMode) errorMkdirAll creates a directory and all parent directories.
Move
func Move(src, dst string) errorMove moves a file or directory from src to dst.
PermString
func PermString(mode os.FileMode) stringPermString 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) errorRemove removes a file or directory.
Resolve
func Resolve(format string, args ...any) stringSymlink
func Symlink(target, link string) errorSymlink creates a symbolic link.
Touch
func Touch(path string) errorTouch creates an empty file or updates the modification time.
Walk
func Walk(root string, walkFn WalkFunc) errorWalk 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) errorWalk walks a directory tree, calling walkFn for each file or directory.