walkie

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "X.X.X"

Functions

This section is empty.

Types

type Directory

type Directory struct {
	Name string `json:"name"`
	// Mtime       time.Time             `json:"mtime"`
	Files       map[string]*File      `json:"files"`
	Directories map[string]*Directory `json:"directories"`
	// contains filtered or unexported fields
}

A Directory with files

func NewDirectory

func NewDirectory(info os.FileInfo) (d *Directory, err error)

func (Directory) DeepEquals

func (d Directory) DeepEquals(x Directory) bool

Equals check recursively if Directory f == Directory x

func (Directory) DiffDir

func (d Directory) DiffDir(ref Directory) (toadd, toremove []string)

Diff for 2 directories structure

func (Directory) DiffFiles

func (d Directory) DiffFiles(ref Directory) (toadd, toremove []string)

Diff for 2 directories structure : files only

func (Directory) Equals

func (d Directory) Equals(x Directory) bool

Equals check recursively if Directory f == Directory x

func (Directory) ListFiles

func (d Directory) ListFiles() (files map[string]*File)

Get all files list

type File

type File struct {
	Name   string    `json:"name"`
	Mtime  time.Time `json:"mtime"`
	Size   int64     `json:"size"`
	SHA256 string    `json:"sha256"`
	// contains filtered or unexported fields
}

A File in the path

func NewFile

func NewFile(path string, info os.FileInfo) (f *File, err error)

NewFile and compute Hash

func (File) Compare added in v0.2.0

func (f File) Compare(x File) (err error)

Compare check if File f == file x and return an error

func (File) Equals

func (f File) Equals(x File) bool

Equals check if File f == file x

type FileCompareError added in v0.2.0

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

func (FileCompareError) Error added in v0.2.0

func (e FileCompareError) Error() string

type UnknownFileError added in v0.2.0

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

func (UnknownFileError) Error added in v0.2.0

func (e UnknownFileError) Error() string

type Walkie

type Walkie struct {
	Directory *Directory
	// contains filtered or unexported fields
}

Walkie service We expect Directory to always be synced

func NewWalkie

func NewWalkie(path string) (walkie *Walkie, err error)

NewWalkie create new Walkie service

func (*Walkie) CleanDir

func (w *Walkie) CleanDir(ref Directory) (nb int, err error)

Delete directories, return number of changed files

func (*Walkie) CleanFiles

func (w *Walkie) CleanFiles(ref Directory) (nb int, err error)

Delete files, return number of changed files

func (*Walkie) Close

func (w *Walkie) Close()

Close Watcher

func (*Walkie) CopyDir

func (w *Walkie) CopyDir(ref Directory) (nb int, err error)

Copy directories, return number of created directories

func (*Walkie) Explore

func (w *Walkie) Explore() (err error)

Explore Directory to make filemap

func (*Walkie) GetDir

func (w *Walkie) GetDir(path string) (dir Directory, found bool)

Get a directory

func (*Walkie) GetFile

func (w *Walkie) GetFile(path string) (file File, found bool)

Get a file

func (*Walkie) ListDirs

func (w *Walkie) ListDirs() (files []string)

Get Subdirectories list

func (*Walkie) ListFiles

func (w *Walkie) ListFiles() (files []string)

Get files directory list

func (*Walkie) Stat

func (w *Walkie) Stat() (nbdir, nbfiles int)

Stats

func (*Walkie) SyncDir

func (w *Walkie) SyncDir(ref Directory) (add, del int, err error)

Synchronize directory

func (*Walkie) UpdateOrCreateFile

func (w *Walkie) UpdateOrCreateFile(path string, r io.Reader, original_file File) (err error)

Create or update a file (use slashes as path)

func (*Walkie) Watch

func (w *Walkie) Watch()

Start Watcher loop

Jump to

Keyboard shortcuts

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