fileutil

package
v1.14.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanCreateSymlinks() bool

CanCreateSymlinks tests to see if it's possible to create a symlink

func CopyDir

func CopyDir(src string, dst string) error

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped. Credit @m4ng0squ4sh https://gist.github.com/m4ng0squ4sh/92462b38df26839a3ca324697c8cba04

func CopyFile

func CopyFile(src string, dst string) error

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage. Credit @m4ng0squ4sh https://gist.github.com/m4ng0squ4sh/92462b38df26839a3ca324697c8cba04

func FgrepStringInFile

func FgrepStringInFile(fullPath string, needle string) (bool, error)

FgrepStringInFile is a small hammer for looking for a literal string in a file. It should only be used against very modest sized files, as the entire file is read into a string.

func FileExists

func FileExists(name string) bool

FileExists checks a file's existence

func FileIsReadable added in v1.8.0

func FileIsReadable(name string) bool

FileIsReadable checks to make sure a file exists and is readable

func IsDirectory added in v1.10.0

func IsDirectory(path string) bool

IsDirectory returns true if path is a dir, false on error or not directory

func IsSameFile added in v1.5.0

func IsSameFile(path1 string, path2 string) (bool, error)

IsSameFile() determines whether two paths refer to the same file/dir

func ListFilesInDir added in v0.15.0

func ListFilesInDir(path string) ([]string, error)

ListFilesInDir returns an array of files found in a directory

func PurgeDirectory

func PurgeDirectory(path string) error

PurgeDirectory removes all of the contents of a given directory, leaving the directory itself intact.

func RandomFilenameBase added in v0.18.0

func RandomFilenameBase() string

RandomFilenameBase generates a temporary filename for use in testing or whatever. From https://stackoverflow.com/a/28005931/215713

func ReadFileIntoString added in v1.5.0

func ReadFileIntoString(path string) (string, error)

ReadFileIntoString just gets the contents of file into string

func RemoveContents added in v1.13.0

func RemoveContents(dir string) error

RemoveContents removes contents of passed directory From https://stackoverflow.com/questions/33450980/how-to-remove-all-contents-of-a-directory-using-golang

func ReplaceSimulatedLinks(path string)

ReplaceSimulatedLinks() walks the path provided and tries to replace XSym links with real ones.

func ReplaceSimulatedXsymSymlinks(links []XSymContents) error

ReplaceSimulatedXsymSymlinks() walks a list of XSymContents and makes real symlinks in their place. This is only valid on Windows host, only works with Docker for Windows (cifs filesystem)

func ReplaceStringInFile added in v1.4.0

func ReplaceStringInFile(searchString string, replaceString string, origPath string, destPath string) error

ReplaceStringInFile takes search and replace strings, an original path, and a dest path, returns error

Types

type XSymContents added in v1.5.0

type XSymContents struct {
	LinkLocation string
	LinkTarget   string
}
func FindSimulatedXsymSymlinks(basePath string) ([]XSymContents, error)

FindSimulatedXsymSymlinks() searches the basePath provided for files whose first line is XSym, which is used in cifs filesystem for simulated symlinks.

Jump to

Keyboard shortcuts

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