cmp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-2.0 Imports: 9 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 {
	// Each of these maps uses a relative path as the key - it
	// is relative to the argument passed to NewTree().
	Left  map[string]*fio.Info
	Right map[string]*fio.Info

	// entries that are only on the left
	LeftOnly []string

	// entries that are only on the right
	RightOnly []string

	// Entries that are identical
	Same []string

	// entries that are different (size, perm, uid, gid, xattr)
	Diff []string

	// entries with same name on both sides but
	// are different (eg entry is a file on one side
	// but a directory in the other)
	Funny []string
}

Difference captures the results of comparing two trees

func DirCmp

func DirCmp(lhs, rhs *Tree, op ...Opt) (*Difference, error)

DirCmp compares two directory trees represented by "lhs" and "rhs". 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()).

func (*Difference) String

func (d *Difference) String() string

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_HARDLINK                        // ignore hardlink count
	IGN_XATTR                           // ignore xattr
)

type Opt

type Opt func(o *opt)

Opt is an option operator for DirCmp.

func WithDeepCompare

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

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

func WithIgnore

func WithIgnore(fl IgnoreFlag) Opt

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

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree represents a file system "tree" traversal object

func NewTree

func NewTree(nm string, opts ...TreeOpt) (*Tree, error)

NewTree creates a new file system traversal. It has no methods or interfaces for public use. It's use is to be an input to DirCmp()

type TreeOpt

type TreeOpt func(o *treeopt)

TreeOpt is an option operator for constructing a filesystem tree object (Tree)

func WithWalkOptions

func WithWalkOptions(wo *walk.Options) TreeOpt

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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