cp

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: BSD-3-Clause Imports: 5 Imported by: 57

Documentation

Overview

Package cp implements routines to copy files.

CopyTree in particular copies entire trees of files.

Only directories, symlinks, and regular files are currently supported.

Index

Constants

This section is empty.

Variables

View Source
var Default = Options{}

Default are the default options. Default follows symlinks.

View Source
var ErrSkip = errors.New("skip")

ErrSkip can be returned by PreCallback to skip a file.

View Source
var NoFollowSymlinks = Options{
	NoFollowSymlinks: true,
}

NoFollowSymlinks is the default options with following symlinks turned off.

Functions

func Copy

func Copy(src, dst string) error

Copy src file to dst file using Default's config.

func CopyTree

func CopyTree(src, dst string) error

CopyTree recursively copies all files in the src tree to dst using Default's config.

Types

type Options

type Options struct {
	// If NoFollowSymlinks is set, Copy copies the symlink itself rather
	// than following the symlink and copying the file it points to.
	NoFollowSymlinks bool

	// PreCallback is called on each file to be copied before it is copied
	// if specified.
	//
	// If PreCallback returns ErrSkip, the file is skipped and Copy returns
	// nil.
	//
	// If PreCallback returns another non-nil error, the file is not copied
	// and Copy returns the error.
	PreCallback func(src, dst string, srcfi os.FileInfo) error

	// PostCallback is called on each file after it is copied if specified.
	PostCallback func(src, dst string)
}

Options are configuration options for how copying files should behave.

func (Options) Copy

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

Copy copies a file at src to dst.

func (Options) CopyTree

func (o Options) CopyTree(src, dst string) error

CopyTree recursively copies all files in the src tree to dst.

Jump to

Keyboard shortcuts

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