Documentation
¶
Index ¶
- Variables
- func ByteSizeStr(sz uint64) string
- func CheckDirExists(path string) (bool, error)
- func CheckFileExists(path string) (bool, error)
- func CheckFileHasContent(fn string, buf []byte) bool
- func DirExists(path string) bool
- func FileExists(path string) bool
- func JSONErrDetail(input string, err error) error
- func JoinPathList(paths ...string) string
- func LineAndCharacter(input string, offset int) (line int, character int, err error)
- func NormalizePathsToSlash(paths []string) []string
- func ReadJSON(fn string, v interface{}) error
- func ResolvesToSameFile(pathA, pathB string) bool
- func SearchDir(dir dirname, accept func(os.FileInfo) bool) []filename
- func SearchFilesAndSymlinks(dirs []string, accept func(os.FileInfo) bool) map[filename][]symlink
- func ValidateDirExists(path string) error
- func ValidateEmptyDirExists(path string) error
- func ValidateFileExists(path string) error
- func ValidateNoDirExists(path string) error
- func ValidateNoFileExists(path string) error
- func ValidateNoPathExists(path string) error
- func ValidatePathExists(path string) error
- func ValidatePathIsAbsolute(path string) error
- func ValidatePathIsNotAbsolute(path string) error
- func WriteFileIfChanged(fn string, buf []byte) error
- func WriteJSON(fn string, v interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileNotDir = errors.New("a file is located at the expected directory location") ErrDirNotFile = errors.New("a directory is located at the expected file location") ErrFileDoesNotExist = os.ErrNotExist ErrDirDoesNotExist = errors.New("directory does not exist") ErrDirIsNotEmpty = errors.New("directory is not empty") ErrPathDoesNotExist = errors.New("path does not exist") ErrFileExists = os.ErrExist ErrDirExists = errors.New("directory already exists") ErrPathIsNotAbsolute = errors.New("path is not absolute") ErrPathIsAbsolute = errors.New("path is absolute") )
Error Codes
Functions ¶
func ByteSizeStr ¶
func CheckDirExists ¶
func CheckFileExists ¶
func CheckFileHasContent ¶
CheckFileHasContent returns true if the specified file exists and has content that matches buf.
func DirExists ¶
DirExists returns true if a directory exists at the specified location. If the path points to a file, this function returns false.
func FileExists ¶
FileExists returns true if a file exists at the specified location. If the path points to a directory, this function returns false.
func JSONErrDetail ¶
JSONErrDetail ammends an error returned from json.Unmarshal with line:position info.
func JoinPathList ¶
JoinPathList joins multiple paths into a string with OS-specific path separator. This is an opposite of the GOLANG's filepath.SplitList() function.
func LineAndCharacter ¶
LineAndCharacter locates line and pos from offset into a file
func NormalizePathsToSlash ¶
NormalizePathsToSlash normalizes a list of file paths: - removes empty paths - converts separators to slashes - removes duplicates - sorts lexicographically
func ResolvesToSameFile ¶
ResolvesToSameFile returns true if the two paths resolve to the same actual file. Follows symlinks.
func SearchDir ¶
SearchDir returns the list of paths within the specified directory that pass through the 'accept' callback. This is a non-recursive search.
func SearchFilesAndSymlinks ¶
SearchFilesAndSymlinks scans the provided set of directories and returns absolute filenames that pass through a functional 'accept' filter.
While searching, symlinks are resolved. For symlinks, the 'accept' is called twice: first on a symlink itself, then on its target.
Returns a map of real absolute file paths and symlinks pointing to those files.
func ValidateDirExists ¶
func ValidateEmptyDirExists ¶
func ValidateFileExists ¶
func ValidateNoDirExists ¶ added in v0.5.0
func ValidateNoFileExists ¶ added in v0.5.0
func ValidateNoPathExists ¶ added in v0.5.0
func ValidatePathExists ¶ added in v0.5.0
func ValidatePathIsAbsolute ¶ added in v0.5.0
func ValidatePathIsNotAbsolute ¶ added in v0.5.0
func WriteFileIfChanged ¶
WriteFileIfChanged writes buf into a file. Does not overwrite if the file already has the specified content. Uses 0666 permission if overwriting is neccessary.
Types ¶
This section is empty.