file

package
v4.0.0-...-ae7b6de Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src, dst string) error

CopyDir copies contents of one directory into another, recursively.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copy a file from source to destination path.

func DirFiles

func DirFiles(dir string) ([]string, error)

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 DirsEqual

func DirsEqual(src, dst string) bool

DirsEqual checks whether two directories have the same content.

func Exists

func Exists(filename string) bool

Exists returns true if a file is not a directory and exists at the specified path.

func ExpandPath

func ExpandPath(p string) (string, error)

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

func HandleBackupDir(dirPath string, permissionOverride bool) error

HandleBackupDir takes an input directory path and either alters its permissions to be usable if it already exists, creates it if not

func HasDir

func HasDir(dirPath string) (bool, error)

HasDir checks if a directory indeed exists at the specified path.

func HasReadWritePermissions

func HasReadWritePermissions(itemPath string) (bool, error)

HasReadWritePermissions checks if file at a path has proper 0600 permissions set.

func HashDir

func HashDir(dir string) (string, error)

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 HashFile

func HashFile(filePath string) ([]byte, error)

HashFile calculates and returns the hash of a file.

func HomeDir

func HomeDir() string

HomeDir for a user.

func MkdirAll

func MkdirAll(dirPath string) error

MkdirAll takes in a path, expands it if necessary, and looks through the permissions of every directory along the path, ensuring we are not attempting to overwrite any existing permissions. Finally, creates the directory accordingly with standardized, Prysm project permissions. This is the static-analysis enforced method for creating a directory programmatically in Prysm.

func ReadFileAsBytes

func ReadFileAsBytes(filename string) ([]byte, error)

ReadFileAsBytes expands a file name's absolute path and reads it as bytes from disk.

func RecursiveFileFind

func RecursiveFileFind(filename, dir string) (bool, string, error)

RecursiveFileFind searches for file in a directory and its subdirectories.

func WriteFile

func WriteFile(file string, data []byte) error

WriteFile is the static-analysis enforced method for writing binary data to a file in Prysm, enforcing a single entrypoint with standardized permissions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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