Skip to content

Commit

Permalink
Change local name copy to copyNextOrSkip
Browse files Browse the repository at this point in the history
DO NOT use the name `copy` since it is reserved by builtin.
Related #60
See #60 (comment)
  • Loading branch information
otiai10 committed May 7, 2021
1 parent 684dfc2 commit 15e6c23
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,17 @@ func switchboard(src, dest string, info os.FileInfo, opt Options) (err error) {
return err
}

// copy decide if this src should be copied or not.
// copyNextOrSkip decide if this src should be copied or not.
// Because this "copy" could be called recursively,
// "info" MUST be given here, NOT nil.
func copy(src, dest string, info os.FileInfo, opt Options) error {
func copyNextOrSkip(src, dest string, info os.FileInfo, opt Options) error {
skip, err := opt.Skip(src)
if err != nil {
return err
}
if skip {
return nil
}

return switchboard(src, dest, info, opt)
}

Expand Down Expand Up @@ -148,7 +147,7 @@ func dcopy(srcdir, destdir string, info os.FileInfo, opt Options) (err error) {
for _, content := range contents {
cs, cd := filepath.Join(srcdir, content.Name()), filepath.Join(destdir, content.Name())

if err = copy(cs, cd, content, opt); err != nil {
if err = copyNextOrSkip(cs, cd, content, opt); err != nil {
// If any error, exit immediately
return
}
Expand All @@ -174,7 +173,7 @@ func onsymlink(src, dest string, info os.FileInfo, opt Options) error {
if err != nil {
return err
}
return copy(orig, dest, info, opt)
return copyNextOrSkip(orig, dest, info, opt)
case Skip:
fallthrough
default:
Expand Down

0 comments on commit 15e6c23

Please sign in to comment.