scanner

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2014 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package scanner implements a file system scanner and hasher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockDiff

func BlockDiff(src, tgt []protocol.BlockInfo) (have, need []protocol.BlockInfo)

BlockDiff returns lists of common and missing (to transform src into tgt) blocks. Both block lists must have been created with the same block size.

func Blocks

func Blocks(r io.Reader, blocksize int, sizehint int64) ([]protocol.BlockInfo, error)

Blocks returns the blockwise hash of the reader.

func HashFile added in v0.10.0

func HashFile(path string, blockSize int) ([]protocol.BlockInfo, error)

func PermsEqual

func PermsEqual(a, b uint32) bool

func Verify added in v0.10.0

func Verify(r io.Reader, blocksize int, blocks []protocol.BlockInfo) error

Verify returns nil or an error describing the mismatch between the block list and actual reader contents

Types

type CurrentFiler

type CurrentFiler interface {
	// CurrentFile returns the file as seen at last scan.
	CurrentFile(name string) protocol.FileInfo
}

type TempNamer

type TempNamer interface {
	// Temporary returns a temporary name for the filed referred to by filepath.
	TempName(path string) string
	// IsTemporary returns true if path refers to the name of temporary file.
	IsTemporary(path string) bool
}

type Walker

type Walker struct {
	// Dir is the base directory for the walk
	Dir string
	// Limit walking to this path within Dir, or no limit if Sub is blank
	Sub string
	// BlockSize controls the size of the block used when hashing.
	BlockSize int
	// List of patterns to ignore
	Ignores ignore.Patterns
	// If TempNamer is not nil, it is used to ignore tempory files when walking.
	TempNamer TempNamer
	// If CurrentFiler is not nil, it is queried for the current file before rescanning.
	CurrentFiler CurrentFiler
	// If IgnorePerms is true, changes to permission bits will not be
	// detected. Scanned files will get zero permission bits and the
	// NoPermissionBits flag set.
	IgnorePerms bool
}

func (*Walker) Walk

func (w *Walker) Walk() (chan protocol.FileInfo, error)

Walk returns the list of files found in the local folder by scanning the file system. Files are blockwise hashed.

Jump to

Keyboard shortcuts

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