file

package
v0.0.0-...-54d0854 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Root folder of this project, needs to be changed if root.go (this file) is moved relative to the root folder
	Root = filepath.Join(filepath.Dir(b), "../..")
)

Functions

func DirExists

func DirExists(file string) bool

func DirFiles

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

DirFiles returns the list of files in the tree rooted at dir, replacing the directory name dir with prefix in each name. The resulting names always use forward slashes.

func Exists

func Exists(file string) bool

func HashDir

func HashDir(dir, prefix string, hash Hash) (string, error)

HashDir returns the hash of the local file system directory dir, replacing the directory name itself with prefix in the file names used in the hash function.

func ReadFile

func ReadFile(source string) ([]byte, error)

Types

type Hash

type Hash func(files []string, open func(string) (io.ReadCloser, error)) (string, error)

A Hash is a directory hash function. It accepts a list of files along with a function that opens the content of each file. It opens, reads, hashes, and closes each file and returns the overall directory hash.

func HashFnv

func HashFnv(allowedSuffix string) Hash

HashFnv is the "hfnv:" directory hash function, using any algorithm.

HashFnv is "hfnv:" followed by the base64-encoded hash of all given files with the allowed suffix specified.

More precisely, the hashed summary contains a single line for each file in the list, ordered by sort.Strings applied to the file names, where each line consists of the hash of the file content, two spaces (U+0020), the file name, and a newline (U+000A).

File names with newlines (U+000A) are disallowed.

Jump to

Keyboard shortcuts

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