copy

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dst string) error

Copy uses the default options to copy src to dst.

Types

type ErrorSkip

type ErrorSkip struct {
	// File is what is being skipped.
	File string
}

ErrorSkip can be returned by PreHook to skip a file when copying.

func NewErrorSkip

func NewErrorSkip(file string) *ErrorSkip

func (*ErrorSkip) Error

func (e *ErrorSkip) Error() string

type Options

type Options struct {
	// Recurse into subdirectories, copying their
	// contents.
	Recursive bool

	// Clobber (overwrite) file or directory if it
	// already exists.
	Clobber bool

	// If FollowSymlinks is set, copy the file pointed to by
	// the symlink instead of the symlink itself.
	FollowSymlinks bool

	// Be verbose, showing each file being copied.
	Verbose bool

	// PreHook is called, if specified, on each file before
	// it is copied.
	//
	// If PreHook returns ErrorSkip, the current file
	// is skipped and Copy returns nil.
	//
	// If PreHook returns another non-nil error, the
	// current file is skipped and Copy returns the error.
	PreHook func(src, dst string, srcInfo os.FileInfo) error

	// PostHook is called, if specified, on the current
	// file after it is copied.
	PostHook func(src, dst string)
}

Options provides configuration for copying.

func GetDefaultOptions

func GetDefaultOptions() Options

GetDefaultOptions returns an Options struct populated with the default options.

func (Options) Copy

func (opt Options) Copy(src, dst string) error

Copy copies a regular file, symlink, or directory located at src to the destination dst, using the options configured.

func (Options) Stat

func (opt Options) Stat(path string) (os.FileInfo, error)

Stat returns a file's information. If path is a symlink, then Stat does or does not follow it based on the value of FollowSymLinks.

Directories

Path Synopsis
Package cmp provides file- and tree-comparison routines.
Package cmp provides file- and tree-comparison routines.

Jump to

Keyboard shortcuts

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