osutil

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanOverwrite added in v0.1.5

func CanOverwrite(path string) (bool, error)

CanOverwrite returns true if the current user can be able to overwrite a file located at path.

func CanStat added in v0.1.4

func CanStat(path string) bool

func CatchAndForwardSignals added in v0.1.5

func CatchAndForwardSignals(proc *os.Process) func()

CatchAndForwardSignals installs handlers for catchable shutdown signals. When such signal is delivered to the parent, it is forwarded to proc; if proc is still alive after 2 seconds it is killed with SIGKILL. Returns a function that should be called when process to which signals are forwarded terminates.

func CurrentUserHomeDir

func CurrentUserHomeDir() (string, error)

CurrentUserHomeDir returns the home directory of the current user.

func IsDebianBased

func IsDebianBased() bool

IsDebianBased returns true if the system is Debian-based by checking for the presence of /etc/debian_version file.

func IsRootOrHomeSubPath

func IsRootOrHomeSubPath(path string) bool

func IsSubDir

func IsSubDir(parent, child string) bool

isSubDirOrSame returns true if child is a sub directory of the parent.

func IsSubDirOrSame

func IsSubDirOrSame(parent, child string) bool

IsSubDirOrSame returns true if child is a sub directory of the parent or if they are the same directory.

func MkdirAll

func MkdirAll(path string) error

MkdirAll is a simple wrapper over os.MkdirAll. It always uses permissions 0700 and returns verbose error which can be propagated up without adding an aditional context.

func TildeToHomeDir

func TildeToHomeDir(path string, homeDir string) string

TildeToHomeDir replaces tilde in a path with the given homeDir path. Does not handle tildes followed by username (~bob).

func ValidateRelPath

func ValidateRelPath(path string) error

ValidateRelPath validates that path is a relative path and is normalized.

func ValidateRootOrHomeSubPath

func ValidateRootOrHomeSubPath(path string) error

ValidateRootOrHomeSubPath validates that a path is a subpath of root or of a ~/, and is normalized.

Types

This section is empty.

Jump to

Keyboard shortcuts

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