fsdiffer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

README

FSDiffer

A simple filesystem differ library that will report added/modified/deleted files.

Pluggable FSdiffers can be used (they just need to implement the FSDiffer interface that is composed by only the Diff() function)

At the moment a simple fs differ is provided. In future additional fs differs will be available (for example an overlayfs differ).

Documentation

Overview

Copyright 2015 Simone Gotti

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeType

type ChangeType uint8
const (
	Added ChangeType = iota
	Modified
	Deleted
)

type FSChange

type FSChange struct {
	Path string
	ChangeType
}

type FSChanges

type FSChanges []*FSChange

FSChanges represents a slice of changes This isn't a map to keep ordering on the changes, for a map see FSChangesMap.

func (FSChanges) ToMap

func (fsc FSChanges) ToMap() FSChangesMap

Utility function to convert an FSChanges slice to a FSChangesMap

type FSChangesMap

type FSChangesMap map[string]ChangeType

FSChanges represents a map of changes, the map's key is the path while the value is the ChangeType

type FSDiffer

type FSDiffer interface {
	Diff() (FSChanges, error)
}

The FSDiffer interface should be implemented from an fsdiffer implementation The returned FSChanges should be lexically ordered like filepath.Walk() does.

type SimpleFSDiffer

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

func NewSimpleFSDiffer

func NewSimpleFSDiffer(sourceDir string, destDir string) *SimpleFSDiffer

func (*SimpleFSDiffer) Diff

func (s *SimpleFSDiffer) Diff() (FSChanges, error)

Creates the FSChanges between sourceDir and destDir. To detect if a file was changed it checks the file's size and mtime (like rsync does by default if no --checksum options is used)

type TemporalFSDiffer

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

TemporalFSDiffer is used to generate changes in a given directory between two different points in time.

func NewTemporalFSDiffer

func NewTemporalFSDiffer(dir string) (*TemporalFSDiffer, error)

NewTemporalFSDiffer creates a new TemporalFSDiffer that will report changes on the given directory.

func (*TemporalFSDiffer) Diff

func (t *TemporalFSDiffer) Diff() (FSChanges, error)

Diff will return any changes to the filesystem in the provided directory since Start was called.

To detect if a file was changed it checks the file's size and mtime (like rsync does by default if no --checksum options is used)

Jump to

Keyboard shortcuts

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