cmp

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: GPL-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Difference

type Difference struct {
	Src string
	Dst string

	// All the entries in the src and dst
	Lhs *fio.FioMap
	Rhs *fio.FioMap

	// Dirs that are only on the left
	LeftDirs *fio.FioMap

	// Files that are only on the left
	LeftFiles *fio.FioMap

	// Dirs that are only on the right
	RightDirs *fio.FioMap

	// Files that are only on the right
	RightFiles *fio.FioMap

	// Dirs that are identical on both sides
	CommonDirs *fio.FioPairMap

	// Files that are identical on both sides
	CommonFiles *fio.FioPairMap

	// Files/dirs that are different on both sides
	Diff *fio.FioPairMap

	// Funny entries
	Funny *fio.FioPairMap
}

Difference captures the results of comparing two directory trees

func Diff added in v0.5.0

func Diff(lhs, rhs *fio.FioMap, opt ...Option) (*Difference, error)

Diff takes two file system trees represented by 'lhs' and 'rhs', and generates the differences between them. It is almost identical to FsTree above - except Diff doesn't do any disk I/O. As a result, the option WithWalkOption is not useful.

func FsTree added in v0.5.0

func FsTree(src, dst string, opt ...Option) (*Difference, error)

FsTree compares two file system trees 'src' and 'dst'. For regular files, it compares file size and mtime to determine change. For all entries, it compares every comparable attribute of fio.Info - unless explicitly ignored (by using the option WithIgnore()). The ignorable attributes are identified by IGN_xxx constants.

func (*Difference) String

func (d *Difference) String() string

type Error added in v0.4.0

type Error struct {
	Op  string
	Src string
	Dst string
	Err error
}

Error represents the errors returned by CloneFile, CloneMetadata and UpdateMetadata

func (*Error) Error added in v0.4.0

func (e *Error) Error() string

Error returns a string representation of Error

func (*Error) Unwrap added in v0.4.0

func (e *Error) Unwrap() error

Unwrap returns the underlying wrapped error

type IgnoreFlag

type IgnoreFlag uint

IgnoreFlag captures the attributes we want to ignore while comparing two fio.Info instances representing two filesystem entries on the two trees being compared.

const (
	IGN_UID   IgnoreFlag = 1 << iota // ignore uid
	IGN_GID                          // ignore gid
	IGN_XATTR                        // ignore xattr
)

func (IgnoreFlag) String added in v0.4.0

func (f IgnoreFlag) String() string

type Observer added in v0.4.3

type Observer interface {
	VisitSrc(fi *fio.Info)
	VisitDst(fi *fio.Info)
}

Observer is invoked when the comparator visits entries in src and dst.

type Option added in v0.4.0

type Option func(o *cmpopt)

Option captures the various options for cloning a directory tree.

func WithConcurrency added in v0.5.0

func WithConcurrency(n int) Option

WithConcurrency limits the use of concurrent goroutines to n.

func WithDeepCompare

func WithDeepCompare(same func(lhs, rhs *fio.Info) bool) Option

WithDeepCompare provides a caller supplied comparison function that will be invoked if all other comparable attributes are identical.

func WithIgnoreAttr added in v0.4.0

func WithIgnoreAttr(fl IgnoreFlag) Option

WithIgnoreAttr captures the attributes of fio.Info that must be ignored for comparing equality of two filesystem entries.

func WithObserver added in v0.4.3

func WithObserver(ob Observer) Option

WithObserver uses 'ob' to report activities as the tree cloner makes progress

func WithWalkOptions

func WithWalkOptions(wo walk.Options) Option

WithWalkOptions uses 'wo' as the option for walk.Walk(); it describes a caller desired traversal of the file system with the requisite input and output filters

Jump to

Keyboard shortcuts

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