fsutils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Error = errors.New("fsutils")
)

Functions

func AvailableSpace

func AvailableSpace(path string) (uint64, error)

AvailableSpace calculates the available space on the filesystem where path resides.

func BackupDir added in v0.4.0

func BackupDir(ctx context.Context, srcDir, outArchive string, removeSrc bool, skip func(string) bool) (err error)

func CountFilesAndDirs added in v0.4.0

func CountFilesAndDirs(dir string) (filec, dirc int, err error)

CountFilesAndDirs counts regular files and directories in dir and its subdirectories.

func DirBtimeSpan added in v0.4.0

func DirBtimeSpan(dir string, recursive bool) (oldest, newest time.Time, bspan time.Duration, err error)

DirBtimeSpan returns the time duration between the oldest and newest file in the directory based on their Btime (creation time). If recursive is true, it includes files in subdirectories; otherwise, it scans only the top-level directory.

func DirSize

func DirSize(dir string) (int64, error)

DirSize calculates the total size of a directory by traversing it and summing the sizes of all encountered files. DirSize calculates the total size of regular files in dir and its subdirectories, excluding symlinks.

func FileSELinuxContext added in v0.4.0

func FileSELinuxContext(f *os.File) (string, error)

FileSELinuxContext retrieves the file's SELinux context (e.g., "unconfined_u:object_r:config_home_t:s0").

func IsDir

func IsDir(path string) bool

IsDir checks if the given path is a directory.

func IsRegular added in v0.2.0

func IsRegular(path string) bool

IsRegular reports whether the path is a regular file. Follows symlinks, so a symlink pointing to a regular file returns true.

func IsStdoutStderrFile added in v0.4.0

func IsStdoutStderrFile(expectedPath string) (bool, error)
func IsSymlink(path string) bool

IsSymlink checks if the given path is a symbolic link.

func SELinuxContext added in v0.4.0

func SELinuxContext(path string) (string, error)

SELinuxContext retrieves the file's SELinux context (e.g., "unconfined_u:object_r:config_home_t:s0") for the given file path.

func UserDataDir added in v0.4.0

func UserDataDir(appslug string) string

UserDataDir returns the platform path for shared persistent data.

func UserRuntimeDir added in v0.4.0

func UserRuntimeDir(appslug string) string

UserRuntimeDir return user runtime dir.

func UserStateDir added in v0.4.0

func UserStateDir(appslug string) string

UserStateDir returns the platform path for shared state data.

Types

type FileInfo added in v0.4.0

type FileInfo struct {
	Name     string
	Atime    time.Time // Last access time
	Btime    time.Time // Birth (creation) time
	Ctime    time.Time // Last status change time
	Mtime    time.Time // Last modification time
	Blksize  uint32
	Nlink    uint32
	Size     uint64
	Blocks   uint64
	Ino      uint64
	Mode     uint16
	Uid      uint32
	Gid      uint32
	DevMajor uint32
	DevMinor uint32
}

FileInfo describes a file it holds file access, birth, change, and modification times.

func FileStat added in v0.4.0

func FileStat(file *os.File) (FileInfo, error)

FileStat retrieves rich file statistics for the given file.

func Stat added in v0.4.0

func Stat(name string) (FileInfo, error)

Stat retrieves rich file statistics for the given file path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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