Documentation ¶
Index ¶
- func CopyFile(srcpath, dstpath string) (err error)
- func DirExists(path string) (bool, error)
- func EmptyDir(path string) error
- func EnsureDir(path string) error
- func EnsureDirAll(path string) error
- func FileExists(path string) (bool, error)
- func FindInPaths(paths []string, baseName string) string
- func GetHomeDirectory() string
- func GetIntraDir(pattern string, depth, length int) string
- func GetNameFromPath(path string, stripExtension bool) string
- func GetWorkingDirectory() string
- func IsFsPathCaseSensitive(path string) (bool, error)
- func IsPathInDir(dir, pathToCheck string) bool
- func IsPathInDirs(dirs []string, pathToCheck string) bool
- func MatchExtension(path string, extensions []string) bool
- func RemoveDir(path string) error
- func SafeMove(src, dst string) error
- func SanitiseBasename(v string) string
- func SymWalk(path string, walkFn filepath.WalkFunc) error
- func Touch(path string) error
- func WriteFile(path string, file []byte) error
- type Cancellable
- type LockContext
- type ReadLockManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶ added in v0.21.0
CopyFile copies the contents of the file at srcpath to a regular file at dstpath. It will copy the last modified timestamp If dstpath already exists the function will fail.
func EnsureDirAll ¶
EnsureDirAll will create a directory at the given path along with any necessary parents if they don't already exist
func FileExists ¶
FileExists returns true if the given path exists and is a file. This function returns false and the error encountered if the call to os.Stat fails.
func FindInPaths ¶
FindInPaths returns the path to baseName in the first path where it exists from paths.
func GetHomeDirectory ¶
func GetHomeDirectory() string
GetHomeDirectory returns the path of the user's home directory. ~ on Unix and C:\Users\UserName on Windows
func GetIntraDir ¶
GetIntraDir returns a string that can be added to filepath.Join to implement directory depth, "" on error eg given a pattern of 0af63ce3c99162e9df23a997f62621c5 and a depth of 2 length of 3 returns 0af/63c or 0af\63c ( dependin on os) that can be later used like this filepath.Join(directory, intradir, basename)
func GetNameFromPath ¶
GetNameFromPath returns the name of a file from its path if stripExtension is true the extension is omitted from the name
func GetWorkingDirectory ¶ added in v0.24.0
func GetWorkingDirectory() string
GetWorkingDirectory returns the current working directory.
func IsFsPathCaseSensitive ¶
IsFsPathCaseSensitive checks the fs of the given path to see if it is case sensitive if the case sensitivity can not be determined false and an error != nil are returned
func IsPathInDir ¶
IsPathInDir returns true if pathToCheck is within dir.
func IsPathInDirs ¶ added in v0.17.0
IsPathInDirs returns true if pathToCheck is within anys of the paths in dirs.
func MatchExtension ¶
MatchExtension returns true if the extension of the provided path matches any of the provided extensions.
func SafeMove ¶
SafeMove attempts to move the file with path src to dest using os.Rename. If this fails, then it copies src to dest, then deletes src.
func SanitiseBasename ¶ added in v0.17.0
SanitiseBasename returns a file basename removing any characters that are illegal or problematic to use in the filesystem.
Types ¶
type Cancellable ¶ added in v0.15.0
type Cancellable interface {
Cancel()
}
type LockContext ¶ added in v0.15.0
func (*LockContext) AttachCommand ¶ added in v0.15.0
func (c *LockContext) AttachCommand(cmd *exec.Cmd)
func (*LockContext) Cancel ¶ added in v0.15.0
func (c *LockContext) Cancel()
type ReadLockManager ¶ added in v0.15.0
type ReadLockManager struct {
// contains filtered or unexported fields
}
ReadLockManager manages read locks on file paths.
func NewReadLockManager ¶ added in v0.15.0
func NewReadLockManager() *ReadLockManager
NewReadLockManager creates a new ReadLockManager.
func (*ReadLockManager) Cancel ¶ added in v0.15.0
func (m *ReadLockManager) Cancel(fn string)
Cancel cancels all read lock contexts associated with fn.
func (*ReadLockManager) ReadLock ¶ added in v0.15.0
func (m *ReadLockManager) ReadLock(ctx context.Context, fn string) *LockContext
ReadLock adds a pending file read lock for fn to its storage, returning a context and cancel function. Per standard WithCancel usage, cancel must be called when the lock is freed.