You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// See https://github.com/otiai10/copy/pull/60#discussion_r627320811 for more details.
// ErrUnsupportedCopyMethod is returned when the FileCopyMethod specified in
10
+
// Options is not supported.
11
+
varErrUnsupportedCopyMethod=errors.New(
12
+
"copy method not supported",
13
+
)
14
+
15
+
// CopyBytes copies the file contents by reading the source file into a buffer,
16
+
// then writing the buffer back to the destination file.
17
+
varCopyBytes=FileCopyMethod{
18
+
fcopy: func(src, deststring, info os.FileInfo, optOptions) (errerror, skipFilebool) {
19
+
varreadcloser io.ReadCloser
20
+
ifopt.FS!=nil {
21
+
readcloser, err=opt.FS.Open(src)
22
+
} else {
23
+
readcloser, err=os.Open(src)
24
+
}
25
+
iferr!=nil {
26
+
ifos.IsNotExist(err) {
27
+
returnnil, true
28
+
}
29
+
return
30
+
}
31
+
deferfclose(readcloser, &err)
32
+
33
+
f, err:=os.Create(dest)
34
+
iferr!=nil {
35
+
return
36
+
}
37
+
deferfclose(f, &err)
38
+
39
+
varbuf []byte=nil
40
+
varw io.Writer=f
41
+
varr io.Reader=readcloser
42
+
43
+
ifopt.WrapReader!=nil {
44
+
r=opt.WrapReader(r)
45
+
}
46
+
47
+
ifopt.CopyBufferSize!=0 {
48
+
buf=make([]byte, opt.CopyBufferSize)
49
+
// Disable using `ReadFrom` by io.CopyBuffer.
50
+
// See https://github.com/otiai10/copy/pull/60#discussion_r627320811 for more details.
0 commit comments