fileutil

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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 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

This section is empty.

Jump to

Keyboard shortcuts

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