fs

package
v12.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package fs provides various filesystem helpers.

Index

Constants

View Source
const DirPermissions = os.ModeDir | 0775

DirPermissions are the default permission bits we apply to directories.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(from string, to string, mode os.FileMode) error

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

func CopyOrLinkFile(from, to string, mode os.FileMode, link, fallback bool) error

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 EnsureDir

func EnsureDir(filename string) error

EnsureDir ensures that the directory of the given file has been created.

func FileExists

func FileExists(filename string) bool

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

func IsGlob(pattern string) bool

IsGlob returns true if the given pattern requires globbing (i.e. contains characters that would be expanded by it)

func IsPackage

func IsPackage(buildFileNames []string, name string) bool

IsPackage returns true if the given directory name is a package (i.e. contains a build file)

func IsSameFile

func IsSameFile(a, b string) bool

IsSameFile returns true if two filenames describe the same underlying file (i.e. inode)

func PathExists

func PathExists(filename string) bool

PathExists returns true if the given path exists, as a file or a directory.

func Walk

func Walk(rootPath string, callback func(name string, isDir bool) error) error

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.

func WriteFile

func WriteFile(fromFile io.Reader, to string, mode os.FileMode) error

WriteFile writes data from a reader to the file named 'to', with an attempt to perform a copy & rename to avoid chaos if anything goes wrong partway.

Types

This section is empty.

Jump to

Keyboard shortcuts

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