commit | 46369e3263f18f3b4a0902ed559994c01683fee4 | [log] [tgz] |
---|---|---|
author | Hiromu OCHIAI <otiai10@gmail.com> | Sun Mar 28 01:24:30 2021 |
committer | GitHub <noreply@github.com> | Sun Mar 28 01:24:30 2021 |
tree | 2c3893db32c5beae11014b118ca45e2acf916022 | |
parent | 51bf83a372fd4023d4dde7ada7f7c4565c6d9af2 [diff] | |
parent | 08af41212dca279a6e1ee562393586c41d8fd9af [diff] |
Merge pull request #54 from otiai10/fix/preservetimes Do not preserve times when Untouchable
copy
copies directories recursively.
err := Copy("your/directory", "your/directory.copy")
// Options specifies optional actions on copying. type Options struct { // OnSymlink can specify what to do on symlink OnSymlink func(src string) SymlinkAction // OnDirExists can specify what to do when there is a directory already existing in destination. OnDirExists func(src, dest string) DirExistsAction // Skip can specify which files should be skipped Skip func(src string) (bool, error) // AddPermission to every entities, // NO MORE THAN 0777 AddPermission os.FileMode // Sync file after copy. // Useful in case when file must be on the disk // (in case crash happens, for example), // at the expense of some performance penalty Sync bool // Preserve the atime and the mtime of the entries // On linux we can preserve only up to 1 millisecond accuracy PreserveTimes bool }
// For example... opt := Options{ Skip: func(src string) { return strings.HasSuffix(src, ".git") }, } err := Copy("your/directory", "your/directory.copy", opt)