dep: github.com/golang/dep/internal/fs Index | Files

package fs

import "github.com/golang/dep/internal/fs"

Index

Package Files

fs.go rename.go

func CopyDir Uses

func CopyDir(src, dst string) error

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.

func EnsureDir Uses

func EnsureDir(path string, perm os.FileMode) error

EnsureDir tries to ensure that a directory is present at the given path. It first checks if the directory already exists at the given path. If there isn't one, it tries to create it with the given permissions. However, it does not try to create the directory recursively.

func EquivalentPaths Uses

func EquivalentPaths(p1, p2 string) (bool, error)

EquivalentPaths compares the paths passed to check if they are equivalent. It respects the case-sensitivity of the underlying filesysyems.

func HasFilepathPrefix Uses

func HasFilepathPrefix(path, prefix string) (bool, error)

HasFilepathPrefix will determine if "path" starts with "prefix" from the point of view of a filesystem.

Unlike filepath.HasPrefix, this function is path-aware, meaning that it knows that two directories /foo and /foobar are not the same thing, and therefore HasFilepathPrefix("/foobar", "/foo") will return false.

This function also handles the case where the involved filesystems are case-insensitive, meaning /foo/bar and /Foo/Bar correspond to the same file. In that situation HasFilepathPrefix("/Foo/Bar", "/foo") will return true. The implementation is *not* OS-specific, so a FAT32 filesystem mounted on Linux will be handled correctly.

func IsCaseSensitiveFilesystem Uses

func IsCaseSensitiveFilesystem(dir string) (bool, error)

IsCaseSensitiveFilesystem determines if the filesystem where dir exists is case sensitive or not.

CAVEAT: this function works by taking the last component of the given path and flipping the case of the first letter for which case flipping is a reversible operation (/foo/Bar → /foo/bar), then testing for the existence of the new filename. There are two possibilities:

1. The alternate filename does not exist. We can conclude that the filesystem is case sensitive.

2. The filename happens to exist. We have to test if the two files are the same file (case insensitive file system) or different ones (case sensitive filesystem).

If the input directory is such that the last component is composed exclusively of case-less codepoints (e.g. numbers), this function will return false.

func IsDir Uses

func IsDir(name string) (bool, error)

IsDir determines is the path given is a directory or not.

func IsNonEmptyDir Uses

func IsNonEmptyDir(name string) (bool, error)

IsNonEmptyDir determines if the path given is a non-empty directory or not.

func IsRegular Uses

func IsRegular(name string) (bool, error)

IsRegular determines if the path given is a regular file or not.

func IsSymlink(path string) (bool, error)

IsSymlink determines if the given path is a symbolic link.

func ReadActualFilenames Uses

func ReadActualFilenames(dirPath string, names []string) (map[string]string, error)

ReadActualFilenames is used to determine the actual file names in given directory.

On case sensitive file systems like ext4, it will check if those files exist using `os.Stat` and return a map with key and value as filenames which exist in the folder.

Otherwise, it reads the contents of the directory and returns a map which has the given file name as the key and actual filename as the value(if it was found).

func RenameWithFallback Uses

func RenameWithFallback(src, dst string) error

RenameWithFallback attempts to rename a file or directory, but falls back to copying in the event of a cross-device link error. If the fallback copy succeeds, src is still removed, emulating normal rename behavior.

Package fs imports 9 packages (graph) and is imported by 145 packages. Updated 2019-02-08. Refresh now. Tools for package owners.