Documentation
¶
Index ¶
- func CanOverwrite(path string) (bool, error)
- func CanRead(path string) bool
- func CanStat(path string) bool
- func CatchAndForwardSignals(proc *os.Process) func()
- func CreateEmptyFile(path string, perm os.FileMode) error
- func CurrentUserHomeDir() (string, error)
- func HomeDirToTilde(path string, homeDir string) string
- func IsDebianBased() bool
- func IsRootOrHomeSubPath(path string) bool
- func IsSubDir(parent, child string) bool
- func IsSubDirOrSame(parent, child string) bool
- func MkdirAll(path string) error
- func TildeToHomeDir(path string, homeDir string) string
- func ValidateRelPath(path string) error
- func ValidateRootOrHomeSubPath(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanOverwrite ¶ added in v0.1.5
CanOverwrite returns true if the current user can be able to overwrite a file located at path.
func CanRead ¶ added in v0.1.8
CanRead returns true if the current user can read the file or directory at path.
func CatchAndForwardSignals ¶ added in v0.1.5
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 CreateEmptyFile ¶ added in v0.1.8
CreateEmptyFile creates an empty file with the given permissions. It fails if the file already exists. Takes umask into account, so the actual permissions of the created file can be reduced.
func CurrentUserHomeDir ¶
CurrentUserHomeDir returns the home directory of the current user.
func HomeDirToTilde ¶ added in v0.1.6
HomeDirToTilde replaces the homeDir prefix in path with "~". If path is not equal to or under homeDir, it is returned unchanged.
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 IsSubDirOrSame ¶
IsSubDirOrSame returns true if child is a sub directory of the parent or if they are the same directory.
func MkdirAll ¶
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 ¶
TildeToHomeDir replaces tilde in a path with the given homeDir path. Does not handle tildes followed by username (~bob).
func ValidateRelPath ¶
ValidateRelPath validates that path is a relative path and is normalized.
func ValidateRootOrHomeSubPath ¶
ValidateRootOrHomeSubPath validates that a path is a subpath of root or of a ~/, and is normalized.
Types ¶
This section is empty.