Skip to content

Commit 1d150c3

Browse files
committed
feat: Add placeholder ReflinkCopy FileCopyMethod
1 parent ad4b1e2 commit 1d150c3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

copy_methods_x.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build !darwin
2+
3+
package copy
4+
5+
import (
6+
"os"
7+
)
8+
9+
// ReflinkCopy tries to copy the file by creating a reflink from the source
10+
// file to the destination file. This asks the filesystem to share the
11+
// contents between the files using a copy-on-write method.
12+
//
13+
// Reflinks are the fastest way to copy large files, but have a few limitations:
14+
//
15+
// - Requires using a supported filesystem (btrfs, xfs, apfs)
16+
// - Source and destination must be on the same filesystem.
17+
//
18+
// See: https://btrfs.readthedocs.io/en/latest/Reflink.html
19+
var ReflinkCopy = FileCopyMethod{
20+
fcopy: func(src, dest string, info os.FileInfo, opt Options) (err error) {
21+
// Not supported os.
22+
return ErrUnsupportedCopyMethod
23+
},
24+
}

options.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Options struct {
3232
//
3333
// Available implementations:
3434
// - CopyBytes (best compatibility)
35+
// - ReflinkCopy (best performance)
3536
//
3637
// Some implementations may not be supported on the target GOOS, or on
3738
// the user's filesystem. When these fail, an error will be returned.

0 commit comments

Comments
 (0)