Skip to content

Commit c6cef34

Browse files
authored
Merge pull request #106 from cpuguy83/export_copy_file
Export `copyFile`
2 parents a88ec15 + d59f454 commit c6cef34

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fs/copy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func copyDirectory(dst, src string, inodes map[uint64]string) error {
7272
if err := os.Link(link, target); err != nil {
7373
return errors.Wrap(err, "failed to create hard link")
7474
}
75-
} else if err := copyFile(source, target); err != nil {
75+
} else if err := CopyFile(target, source); err != nil {
7676
return errors.Wrap(err, "failed to copy files")
7777
}
7878
case (fi.Mode() & os.ModeSymlink) == os.ModeSymlink:
@@ -103,7 +103,9 @@ func copyDirectory(dst, src string, inodes map[uint64]string) error {
103103
return nil
104104
}
105105

106-
func copyFile(source, target string) error {
106+
// CopyFile copies the source file to the target.
107+
// The most efficient means of copying is used for the platform.
108+
func CopyFile(target, source string) error {
107109
src, err := os.Open(source)
108110
if err != nil {
109111
return errors.Wrapf(err, "failed to open source %s", source)

0 commit comments

Comments
 (0)