files

package module
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: BSD-3-Clause Imports: 10 Imported by: 4

README

files

Functions that has to do with files and/or directories.

  • Version: 1.4.2
  • License: BSD-3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinDirectory

func BinDirectory(filename string) bool

BinDirectory will check if the given filename is in one of these directories: /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin, ~/.bin, ~/bin, ~/.local/bin

func CanRead added in v1.1.0

func CanRead(filename string) bool

CanRead checks if 1 byte can actually be read from the given filename

func DataReadyOnStdin

func DataReadyOnStdin() bool

DataReadyOnStdin checks if data is ready on stdin

func Exists

func Exists(path string) bool

Exists checks if the given path exists

func FileHas

func FileHas(path, what string) bool

FileHas checks if the given file exists and contains the given string

func FilterOutBinaryFiles

func FilterOutBinaryFiles(filenames []string) []string

FilterOutBinaryFiles filters out files that are either binary or can not be read

func IsBinary added in v1.4.0

func IsBinary(filename string) bool

IsBinary returns true if the given filename can be read and is a binary file

func IsDir

func IsDir(path string) bool

IsDir checks if the given path exists and is a directory

func IsFile

func IsFile(path string) bool

IsFile checks if the given path exists and is a regular file

func IsFileOrSymlink(path string) bool

IsFileOrSymlink checks if the given path exists and is a regular file or a symbolic link

func IsSymlink(path string) bool

IsSymlink checks if the given path exists and is a symbolic link

func ReadString added in v1.1.0

func ReadString(filename string) string

ReadString returns the contents of the given filename as a string. Returns an empty string if there were errors.

func Relative added in v1.4.2

func Relative(path string) string

Relative takes an absolute or relative path and attempts to return it relative to the current directory. If there are errors, it simply returns the given path.

func ShortPath

func ShortPath(path string) string

ShortPath replaces the home directory with ~ in a given path. The given path is expected to contain the home directory path either 0 or 1 times, and if it contains the path to the home directory, it is expected to be at the start of the given string.

func TimestampedFilename

func TimestampedFilename(filename string) string

TimestampedFilename prefixes the given filename with a timestamp

func Which

func Which(executable string) string

Which tries to find the given executable name in the $PATH Returns an empty string if not found.

Types

This section is empty.

Jump to

Keyboard shortcuts

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