Documentation ¶
Index ¶
- func Abs(path string) (string, error)
- func CopyFile(from, to string, mode os.FileMode) (err error)
- func CopyFileAtomic(from, to string, mode os.FileMode) (err error)
- func EnsureFileWithPermission(fn string, mode os.FileMode) error
- func EvalRelative(path string, root string) string
- func FindSize(size int64) string
- func FirstExistingParent(path string) (string, error)
- func ForceRemoveAll(path string) error
- func IsDir(name string) bool
- func IsExec(name string) bool
- func IsFile(name string) bool
- func IsLink(name string) bool
- func IsOwner(name string, uid uint32) bool
- func IsReadable(path string) bool
- func IsSuid(name string) bool
- func IsWritable(path string) bool
- func MakeTmpDir(basedir, pattern string, mode os.FileMode) (string, error)
- func MakeTmpFile(basedir, pattern string, mode os.FileMode) (*os.File, error)
- func Mkdir(path string, mode os.FileMode) error
- func MkdirAll(path string, mode os.FileMode) error
- func PathExists(path string) (bool, error)
- func PermWalk(root string, walkFn filepath.WalkFunc) error
- func PermWalkRaiseError(root string, walkFn filepath.WalkFunc) error
- func RootDir(path string) string
- func Touch(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
CopyFile copies file to the provided location making sure the resulting file has permission bits set to the mode prior to umask. To honor umask correctly the resulting file must not exist.
func CopyFileAtomic ¶
CopyFileAtomic copies file to a temporary file in the same destination directory and the renames to the final name. This is useful to avoid races where concurrent copies could happen to the same destination. It makes sure the resulting file has permission bits set to the mode prior to umask. To honor umask correctly the resulting file must not exist.
func EnsureFileWithPermission ¶
EnsureFileWithPermission takes a file path, and 1. Creates it with the specified permission, or 2. ensures a file is the specified permission.
func EvalRelative ¶
EvalRelative evaluates symlinks in path relative to root path, it returns a path as if it was evaluated from chroot. This function always returns an absolute path and is intended to be used to resolve mount points destinations, it helps the runtime to not bind mount directories/files outside of the container image provided by the root argument.
func FindSize ¶
FindSize takes a size in bytes and converts it to a human-readable string representation expressing kB, MB, GB or TB (whatever is smaller, but still larger than one).
func FirstExistingParent ¶
FirstExistingParent walks up the supplied path and returns the first parent that exists. If the supplied path exists, it will just return that path. Assumes cwd and the root directory always exists
func ForceRemoveAll ¶
ForceRemoveAll removes a directory like os.RemoveAll, except that it will chmod any directory who's permissions are preventing the removal of contents
func IsReadable ¶ added in v1.1.0
IsReadable returns true if the file that is passed in is readable by the user (note: uid is checked, not euid).
func IsWritable ¶
IsWritable returns true if the file that is passed in is writable by the user (note: uid is checked, not euid).
func MakeTmpDir ¶
MakeTmpDir creates a temporary directory with provided mode in os.TempDir if basedir is "". This function assumes that basedir exists, so it's the caller's responsibility to create it before calling it.
func MakeTmpFile ¶
MakeTmpFile creates a temporary file with provided mode in os.TempDir if basedir is "". This function assumes that basedir exists, so it's the caller's responsibility to create it before calling it.
func MkdirAll ¶
MkdirAll creates a directory and parents if it doesn't exist with mode after umask reset.
func PathExists ¶
PathExists simply checks if a path exists.
func PermWalk ¶
PermWalk is similar to filepath.Walk - but:
- The skipDir checks are removed (we never want to skip anything here)
- Our walk will call walkFn on a directory *before* attempting to look inside that directory.
func PermWalkRaiseError ¶
PermWalkRaiseError is similar to filepath.Walk - but:
- The skipDir checks are removed (we never want to skip anything here)
- Our walk will call walkFn on a directory *before* attempting to look inside that directory.
- We back out of the recursion at the *first* error... we don't attempt to go through as much as we can.
Types ¶
This section is empty.