fsys

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFileOpen means file open error.
	ErrFileOpen = errors.New("fsys: file open error")

	// ErrFileCreate means file create error.
	ErrFileCreate = errors.New("fsys: file create error")

	// ErrFileCopy means file copy error.
	ErrFileCopy = errors.New("fsys: file copy error")

	// ErrFileDel means file del error.
	ErrFileDel = errors.New("fsys: file del error")
)

FILES

View Source
var (
	// ErrWalk means walk error.
	ErrWalk = errors.New("fsys: walk error")

	// ErrDirCreate means dir create error.
	ErrDirCreate = errors.New("fsys: dir create error")

	// ErrDirMv means dir move attempt.
	ErrDirMv = errors.New("fsys: only files permitted for move")
)

DIR

View Source
var (
	// ErrStat means stat error.
	ErrStat = errors.New("fsys: stat error")

	// ErrChmod means chmod error.
	ErrChmod = errors.New("fsys: chmod error")

	// ErrChown means chown error.
	ErrChown = errors.New("fsys: chown error")
)

MODE

View Source
var (
	// ErrPathInvalid means invalid path format.
	ErrPathInvalid = errors.New("fsys: invalid path format")

	// ErrPathRoot means root path not permitted.
	ErrPathRoot = errors.New("fsys: root path not permitted")

	// ErrPathNotAbs means path not absolute.
	ErrPathNotAbs = errors.New("fsys: path not absolute")
)

VALIDATION

View Source
var (
	// ErrTOMLRead means toml read error.
	ErrTOMLRead = errors.New("fsys: toml read error")

	// ErrTOMLWrite means toml write error.
	ErrTOMLWrite = errors.New("fsys: toml write error")
)

TOML

Functions

func HasDotDots

func HasDotDots(paths ...string) error

HasDotDots validates paths against dot dots, relative, root or current dir.

func InstallTOML

func InstallTOML(path string, cfg any) error

InstallTOML installs a toml file by first checking if a matching .toml file exists and if not, will write the file but with file extension .disabled.

func IsExp added in v1.2.2

func IsExp(expiry time.Time, path string) (bool, *unix.Stat_t)

IsExp verifies is a file has exceeded max mtime. Timestomp protection with ctime.

func IsRel

func IsRel(path string, bases ...string) bool

IsRel verifies if a path is relative to a base path.

func MntPoint

func MntPoint(path string) (string, error)

MntPoint returns a given path's mnt point.

func Mv

func Mv(srcPath string, dstPath string, attr *Attr) error

Mv moves files across different mnts. uid and gid only apply for files.

func QuarantinePath

func QuarantinePath(quarantineDir string, path string) string

QuarantinePath returns a path's quarantine path from given parent dir and detection path.

func ReadTOML

func ReadTOML(path string, cfg any) error

ReadTOML reads a toml file for given cfg.

func Walk

func Walk(path string) ([]string, error)

Walk returns a recursive file list for a path.

func WalkByExt

func WalkByExt(path string, exts ...string) ([]string, error)

WalkByExt returns a recursive file list for a given path and extesion(s).

func WriteTOML

func WriteTOML(path string, cfg any) error

WriteTOML (over)writes a toml file with given cfg.

Types

type Attr

type Attr struct {
	UID   int         `json:"uid"`
	GID   int         `json:"gid"`
	Mode  fs.FileMode `json:"mode"`
	CTime time.Time   `json:"ctime"`
	MTime time.Time   `json:"mtime"`
}

Attr represents file attributes.

func NewAttr

func NewAttr(stat *unix.Stat_t) *Attr

NewAttr returns an attr from given stat.

Jump to

Keyboard shortcuts

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