shutil

package
v0.3.0-rc.2.0...-51e5094 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dst string, followSymlinks bool) (string, error)

Copy data and mode bits ("cp src dst"). Return the file's destination.

The destination may be a directory.

If followSymlinks is false, symlinks won't be followed. This resembles GNU's "cp -P src dst".

If source and destination are the same file, a SameFileError will be rased.

func CopyFile

func CopyFile(src, dst string, followSymlinks bool) error

Copy data from src to dst

If followSymlinks is not set and src is a symbolic link, a new symlink will be created instead of copying the file it points to.

func CopyMode

func CopyMode(src, dst string, followSymlinks bool) error

Copy mode bits from src to dst.

If followSymlinks is false, symlinks aren't followed if and only if both `src` and `dst` are symlinks. If `lchmod` isn't available and both are symlinks this does nothing. (I don't think lchmod is available in Go)

func CopyTree

func CopyTree(src, dst string, options *CopyTreeOptions) error

Recursively copy a directory tree.

The destination directory must not already exist.

If the optional Symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. If the file pointed by the symlink doesn't exist, an error will be returned.

You can set the optional IgnoreDanglingSymlinks flag to true if you want to silence this error. Notice that this has no effect on platforms that don't support os.Symlink.

The optional ignore argument is a callable. If given, it is called with the `src` parameter, which is the directory being visited by CopyTree(), and `names` which is the list of `src` contents, as returned by ioutil.ReadDir():

callable(src, entries) -> ignoredNames

Since CopyTree() is called recursively, the callable will be called once for each directory that is copied. It returns a list of names relative to the `src` directory that should not be copied.

The optional copyFunction argument is a callable that will be used to copy each file. It will be called with the source path and the destination path as arguments. By default, Copy() is used, but any function that supports the same signature (like Copy2() when it exists) can be used.

func IsSymlink(fi os.FileInfo) bool

Types

type AlreadyExistsError

type AlreadyExistsError struct {
	Dst string
}

func (AlreadyExistsError) Error

func (e AlreadyExistsError) Error() string

type CopyTreeOptions

type CopyTreeOptions struct {
	Symlinks               bool
	IgnoreDanglingSymlinks bool
	CopyFunction           func(string, string, bool) (string, error)
	Ignore                 func(string, []os.FileInfo) []string
}

type NotADirectoryError

type NotADirectoryError struct {
	Src string
}

func (NotADirectoryError) Error

func (e NotADirectoryError) Error() string

type SameFileError

type SameFileError struct {
	Src string
	Dst string
}

func (SameFileError) Error

func (e SameFileError) Error() string

type SpecialFileError

type SpecialFileError struct {
	File     string
	FileInfo os.FileInfo
}

func (SpecialFileError) Error

func (e SpecialFileError) Error() string

Jump to

Keyboard shortcuts

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