fsync

package module
v0.0.0-...-6c37e28 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2015 License: MIT Imports: 7 Imported by: 2

README

Package fsync keeps files and directories in sync. Read the documentation on GoDoc.

Documentation

Overview

package fsync keeps two files or directories in sync.

err := fsync.Sync("~/dst", ".")

After the above code, if err is nil, every file and directory in the current directory is copied to ~/dst and has the same permissions. Consequent calls will only copy changed or new files.

SyncTo is a helper function which helps you sync a groups of files or directories into a signle destination. For instance, calling

SyncTo("public", "build/app.js", "build/app.css", "images", "fonts")

is equivalient to calling

Sync("public/app.js", "build/app.js")
Sync("public/app.css", "build/app.css")
Sync("public/images", "images")
Sync("public/fonts", "fonts")

Actually, this is how SyncTo is implemented: consequent calls to Sync.

By default, sync code ignores extra files in the destination that don’t have identicals in the source. Setting Delete field of a Syncer to true changes this behavior and deletes these extra files.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileOverDir = errors.New(
		"fsync: trying to overwrite a non-empty directory with a file")
)

Functions

func Sync

func Sync(dst, src string) error

Sync copies files and directories inside src into dst.

func SyncTo

func SyncTo(to string, srcs ...string) error

SyncTo syncs srcs files and directories into to directory.

Types

type Syncer

type Syncer struct {
	// Set this to true to delete files in the destination that don't exist
	// in the source.
	Delete bool
	// By default, modification times are synced. This can be turned off by
	// setting this to true.
	NoTimes bool
}

Type Syncer provides functions for syncing files.

func NewSyncer

func NewSyncer() *Syncer

NewSyncer creates a new instance of Syncer with default options.

func (*Syncer) Sync

func (s *Syncer) Sync(dst, src string) error

Sync copies files and directories inside src into dst.

func (*Syncer) SyncTo

func (s *Syncer) SyncTo(to string, srcs ...string) error

SyncTo syncs srcs files or directories into to directory.

Jump to

Keyboard shortcuts

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