Documentation ¶
Index ¶
- Constants
- func AbsPath(rootPath string, path string) string
- func AbsPaths(rootPath string, paths []string) []string
- func BackupFile(filepath string) error
- func DirsExist(paths ...string) error
- func FileExists(path string) bool
- func FileGlob(pattern string) ([]string, error)
- func FileHasOwnerExecPerm(p string) (bool, error)
- func FileReadLine(path string) (string, error)
- func FileSize(path string) (int64, error)
- func FindDirInParentDirs(startPath, dirname string) (string, error)
- func FindFileInParentDirs(startPath, filename string) (string, error)
- func FindFilesInSubDir(searchDir, filename string, maxdepth int) ([]string, error)
- func IsDir(path string) (bool, error)
- func IsFile(path string) (bool, error)
- func IsRegularFile(path string) (bool, error)
- func MatchGlob(pattern, path string) (bool, error)
- func Mkdir(path string) error
- func OwnerHasExecPerm(m fs.FileMode) bool
- func PathsJoin(rootPath string, relPaths []string) []string
- func RealPath(path string) (string, error)
- func RealPathRel(basepath, path string) (string, error)
- func SameFile(a, b string) (bool, error)
Constants ¶
const FileBackupSuffix = ".bak"
Variables ¶
This section is empty.
Functions ¶
func AbsPath ¶
AbsPath ensures that path is an absolute path. If it isn't, it is joined with rootPath.
func AbsPaths ¶
AbsPaths ensures that all elements in paths are absolute paths. If an element is not an absolute path, it is joined with rootPath.
func BackupFile ¶
BackupFile renames a file to <OldName><FileBackupSuffix>.
func FileExists ¶
FileExists returns true if path exist and is a file
func FileGlob ¶
FileGlob resolves the pattern to file paths. If the pattern is an absolute path, absolute paths are returned, otherwise relative paths. Files are resolved in the same way then filepath.Glob() does, with the following exceptions:
- it also supports '**' to match files and directories recursively,
- it only returns paths to files, no directory paths,
- if a part of the pattern is a path and it does not exist an error that can be tested with os.IsNotExist() is returned.
If a globPath doesn't match any files an empty []string is returned and error is nil
func FileHasOwnerExecPerm ¶
FileHasOwnerExecPerm returns true if the executable mode bit for the file owner is set.
func FileReadLine ¶
FileReadLine reads the first line from a file
func FindDirInParentDirs ¶
FindDirInParentDirs finds a directory in startPath or its parent directories. The function starts looking for a directory called dirname in startPath and then checks recursively its parent directories. It returns the absolute path of the first match. If it reaches the root directory without finding the directory it returns os.ErrNotExist.
func FindFileInParentDirs ¶
FindFileInParentDirs finds a file in startPath or its parent directories. The function starts looking for a file called filename in startPath and then checks recursively its parent directories. It returns the absolute path of the first match. If it reaches the root directory without finding the file it returns os.ErrNotExist.
func FindFilesInSubDir ¶
FindFilesInSubDir returns all directories that contain filename that are in searchDir. The function descends up to maxdepth levels of directories below searchDir
func IsDir ¶
IsDir returns true if the path is a directory. If the directory does not exist, the error from os.Stat() is returned.
func IsFile ¶
IsFile returns true if path is a file. If the path does not exist an error is returned
func IsRegularFile ¶
IsRegularFile returns true if path is a regular file. If the directory does not exist, the error from os.Stat() is returned.
func OwnerHasExecPerm ¶
OwnerHasExecPerm returns true if the executable mode bit in m is set.
func RealPathRel ¶
RealPath resolves all symlinks and returns the path relative to basepath.
Types ¶
This section is empty.