fileutil

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalPath added in v0.1.3

func CanonicalPath(path string) (string, error)

CanonicalPath converts path to an absolute path and follows all symlinks (if any). If path doesn't exist, no parent symlinks are followed.

func Cleanup

func Cleanup(path string)

Cleanup removes the specified file or directory and prints any errors to stderr. It's supposed to be used in defer statements to clean up temporary directories.

func Exists

func Exists(path string) (bool, error)
func ForceSymlink(oldname, newname string) error

ForceSymlink creates newname as a symbolic link to oldname. If newname already exists, it will be overwritten.

func IsBelow

func IsBelow(path string, root string) (bool, error)

IsBelow returns true if and only if path lies below or is the path root. path and root must be either both absolute or both relative.

func IsDir

func IsDir(path string) bool

IsDir returns whether this path is a directory. Tries to behave the same as Python's pathlib.Path.is_dir()

func IsSymlink(path string) bool

func PrettifyPath

func PrettifyPath(path string) string

PrettifyPath prints a possibly shortened path for display purposes. If path is located under the current working directory, the relative path to it is returned, otherwise or in case of an error the path is returned unchanged.

func Touch

func Touch(path string) error

Touch creates a file at the given path

Types

This section is empty.

Jump to

Keyboard shortcuts

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