fs

package
v0.0.0-...-9f53a2b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adler32Sum

func Adler32Sum(filePath string) (checksum string, err error)

Adler32Sum calculates and returns the adler32 checksum for the file in the given path

func Sha1Sum

func Sha1Sum(filePath string) (checksum string, err error)

Sha1Sum calculates and returns the sha1 checksum for the file in the given path

Types

type FileInfo

type FileInfo interface {
	Name() string
	Size() int64
	Mode() os.FileMode
	Path() string
	FileSystem() string
	Inode() (uint64, error)
	Fingerprint() (string, error) // Fingerprint of the files contents. Files with the same fingerpint hold the same data.
}

FileInfo groups information about a certain file

func NewFileInfo

func NewFileInfo(fi os.FileInfo, path string) FileInfo

NewFileInfo creates a new FileInfo object for the file at a given path

type FileOnDiskInfo

type FileOnDiskInfo struct {
	FileInfo    FileInfo
	InodeInfo   InodeInfo
	Fingerprint string // Fingerprint of the Inodes contents. Inodes with the same fingerpint hold the same data.
}

FileOnDiskInfo combines the information about a file, its filesystem storage place and its data

func GenerateFileOnDiskInfo

func GenerateFileOnDiskInfo(fileInfo FileInfo, knownFingerprints map[string]string) (*FileOnDiskInfo, error)

GenerateFileOnDiskInfo calculates the fingerprint of the given FileInfo object and also collects inode information on it

type HashFunction

type HashFunction func(filePath string) (checksum string, err error)

HashFunction is the type of a function which reads a file and calculates a checksum on it

type InodeInfo

type InodeInfo interface {
	Address() string // Address of the Inode, unique to the running machine. Includes an identifier of the filesystem
}

InodeInfo represents all necessary information about the filesystem representation of a file (inodes on Unix)

func InodeInfoFromFileInfo

func InodeInfoFromFileInfo(fi FileInfo) (InodeInfo, error)

InodeInfoFromFileInfo creates a new InodeInfo object from the information of the given FileInfo object