Documentation ¶
Index ¶
- func CopyDir(src, dst string) error
- func CopyFile(src, dst string) error
- func DirFiles(dir string) ([]string, error)
- func DirsEqual(src, dst string) bool
- func Exists(filename string, objType ObjType) (bool, error)
- func ExpandPath(p string) (string, error)
- func HandleBackupDir(dirPath string, permissionOverride bool) error
- func HasDir(dirPath string) (bool, error)
- func HasReadWritePermissions(itemPath string) (bool, error)
- func HashDir(dir string) (string, error)
- func HashFile(filePath string) ([]byte, error)
- func HomeDir() string
- func MkdirAll(dirPath string) error
- func ReadFileAsBytes(filename string) ([]byte, error)
- func RecursiveDirFind(dirname, dir string) (bool, string, error)
- func RecursiveFileFind(filename, dir string) (bool, string, error)
- func WriteFile(file string, data []byte) error
- func WriteLinesToFile(lines []string, filename string) error
- type ObjType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirFiles ¶
DirFiles returns list of files found within a given directory and its sub-directories. Directory prefix will not be included as a part of returned file string i.e. for a file located in "dir/foo/bar" only "foo/bar" part will be returned.
func ExpandPath ¶
ExpandPath given a string which may be a relative path. 1. replace tilde with users home dir 2. expands embedded environment variables 3. cleans the path, e.g. /a/b/../c -> /a/c Note, it has limitations, e.g. ~someuser/tmp will not be expanded
func HandleBackupDir ¶
HandleBackupDir takes an input directory path and either alters its permissions to be usable if it already exists, creates it if not
func HasReadWritePermissions ¶
HasReadWritePermissions checks if file at a path has proper 0600 permissions set.
func HashDir ¶
HashDir calculates and returns hash of directory: each file's hash is calculated and saved along with the file name into the list, after which list is hashed to produce the final signature. Implementation is based on https://github.com/golang/mod/blob/release-branch.go1.15/sumdb/dirhash/hash.go
func MkdirAll ¶
MkdirAll takes in a path, expands it if necessary, and creates the directory accordingly with standardized, Prysm project permissions. If a directory already exists as this path, then the method returns without making any changes. This is the static-analysis enforced method for creating a directory programmatically in Prysm.
func ReadFileAsBytes ¶
ReadFileAsBytes expands a file name's absolute path and reads it as bytes from disk.
func RecursiveDirFind ¶ added in v5.0.2
RecursiveDirFind searches for directory in a directory and its subdirectories.
func RecursiveFileFind ¶
RecursiveFileFind searches for file in a directory and its subdirectories.
func WriteFile ¶
WriteFile is the static-analysis enforced method for writing binary data to a file in Prysm, enforcing a single entrypoint with standardized permissions.
func WriteLinesToFile ¶ added in v5.1.0
WriteLinesToFile writes a slice of strings to a file, each string on a new line.