Documentation ¶
Overview ¶
Package fs provides various filesystem helpers.
Index ¶
- Constants
- func CopyFile(from string, to string, mode os.FileMode) error
- func CopyOrLinkFile(from, to string, mode os.FileMode, link, fallback bool) error
- func EnsureDir(filename string) error
- func FileExists(filename string) bool
- func Glob(buildFileNames []string, rootPath string, ...) []string
- func IsGlob(pattern string) bool
- func IsPackage(buildFileNames []string, name string) bool
- func IsSameFile(a, b string) bool
- func PathExists(filename string) bool
- func Walk(rootPath string, callback func(name string, isDir bool) error) error
- func WalkMode(rootPath string, ...) error
- func WriteFile(fromFile io.Reader, to string, mode os.FileMode) error
Constants ¶
const DirPermissions = os.ModeDir | 0775
DirPermissions are the default permission bits we apply to directories.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
CopyFile copies a file from 'from' to 'to', with an attempt to perform a copy & rename to avoid chaos if anything goes wrong partway.
func CopyOrLinkFile ¶
CopyOrLinkFile either copies or hardlinks a file based on the link argument. Falls back to a copy if link fails and fallback is true.
func FileExists ¶
FileExists returns true if the given path exists and is a file.
func Glob ¶
func Glob(buildFileNames []string, rootPath string, includes, prefixedExcludes, excludes []string, includeHidden bool) []string
Glob implements matching using Go's built-in filepath.Glob, but extends it to support Ant-style patterns using **.
func IsGlob ¶
IsGlob returns true if the given pattern requires globbing (i.e. contains characters that would be expanded by it)
func IsPackage ¶
IsPackage returns true if the given directory name is a package (i.e. contains a build file)
func IsSameFile ¶
IsSameFile returns true if two filenames describe the same underlying file (i.e. inode)
func PathExists ¶
PathExists returns true if the given path exists, as a file or a directory.
func Walk ¶
Walk implements an equivalent to filepath.Walk. It's implemented over github.com/karrick/godirwalk but the provided interface doesn't use that to make it a little easier to handle.
func WalkMode ¶
func WalkMode(rootPath string, callback func(name string, isDir bool, mode os.FileMode) error) error
WalkMode is like Walk but the callback receives an additional type specifying the file mode type. N.B. This only includes the bits of the mode that determine the mode type, not the permissions.
Types ¶
This section is empty.