Documentation ¶
Index ¶
- func Copy(src, dst string, followSymlinks bool) (string, error)
- func CopyFile(src, dst string, followSymlinks bool) error
- func CopyMode(src, dst string, followSymlinks bool) error
- func CopyTree(src, dst string, options *CopyTreeOptions) error
- func IsSymlink(fi os.FileInfo) bool
- type AlreadyExistsError
- type CopyTreeOptions
- type NotADirectoryError
- type SameFileError
- type SpecialFileError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
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 ¶
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 ¶
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.
Types ¶
type AlreadyExistsError ¶
type AlreadyExistsError struct {
Dst string
}
func (AlreadyExistsError) Error ¶
func (e AlreadyExistsError) Error() string
type CopyTreeOptions ¶
type NotADirectoryError ¶
type NotADirectoryError struct {
Src string
}
func (NotADirectoryError) Error ¶
func (e NotADirectoryError) Error() string
type SameFileError ¶
func (SameFileError) Error ¶
func (e SameFileError) Error() string
type SpecialFileError ¶
func (SpecialFileError) Error ¶
func (e SpecialFileError) Error() string