api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2016 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const HASHSIZE = 64

HASHSIZE defines the maximum digest size in bytes some implemented hash algorithm uses

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HashSpec          HashingSpec
	HashAlgorithm     string
	TraversalStrategy string
}

Config stores any configuration necessary to run the application

type Entry

type Entry struct {
	Base   string
	Path   string
	Hash   [HASHSIZE]byte
	Parent *Entry
	IsDir  bool
}

Entry stores data about file system nodes

type EqChannel

type EqChannel chan<- []*Entry

EqChannel defines a channel receiving an array of Entry instance representing equivalent file system entries

type FindDuplicates

type FindDuplicates func(conf Config, srcs []Source, out chan [][2]string) error

FindDuplicates implements the main functionality to detect duplicate file system nodes in Sources using the given Config and prints the result as array of string to the out channel.

This is the only public API function

type HashingAlgorithm

type HashingAlgorithm interface {
	// HashFile content or any data of a file according to some hashFileSpec.
	// The file is specified with a relative path and the hash stored in digest.
	HashFile(spec HashingSpec, relPath string, digest []byte) error

	// HashString hashes a given string and stores the result in digest
	HashString(hashme string, digest []byte) error

	// HashTwoHashes hashes two given hashes
	HashTwoHashes(input1 []byte, input2 []byte, digest []byte) error

	// HashDirectory updates the parent hash value with the child hash value
	HashDirectory(parent []byte, child []byte) error

	// String returns the hash algorithm's name in human-readable form
	String() string
}

HashingAlgorithm is the generic interface for all hash algorithm implementations to be used

type HashingSpec

type HashingSpec struct {
	FileContent    bool
	FilePerm       bool
	FileAbsPath    bool
	FileRelPath    bool
	FileBasename   bool
	FileOwner      bool
	FileGroup      bool
	FileExt        bool
	FileSize       bool
	FileMtime      bool
	FileAtime      bool
	FolderBasename bool
}

HashingSpec specifies which attributes shall be considered in a hash

func (*HashingSpec) Any

func (h *HashingSpec) Any() bool

Any checks whether any boolean flag of HashingSpec is set

type Match

type Match func(conf *Config, trees []*Tree, eqChan EqChannel) error

Match takes Tree instances and determines equivalent file system entries

type Source

type Source struct {
	Path string
	Name string
}

Source represents a file system node whose subtree will be retrieved

type Traverse

type Traverse func(conf *Config, src *Source, tr *Tree) error

Traverse retrieves traversal results and returns them as a tree

type Traversing

type Traversing func(conf *Config, src *Source, root *Entry, out chan *Entry) error

Traversing is a function traversing a hierarchy of file system entries

type Tree

type Tree struct {
	Root   *Entry
	Path   string
	Hashes map[[HASHSIZE]byte]*Entry
}

Tree represents a parsed file system subtree

Jump to

Keyboard shortcuts

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