Skip to content

Commit

Permalink
copy dir
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Sverdlov <[email protected]>
  • Loading branch information
sverdlov93 committed Aug 31, 2023
1 parent a2be3c3 commit 15c2382
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions utils/fileutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,31 +411,28 @@ func CopyDir(fromPath, toPath string, includeDirs bool, excludeNames []string) e
return err
}

for _, v := range files {
for _, file := range files {
fileName := filepath.Base(file)
// Skip if excluded
if slices.Contains(excludeNames, filepath.Base(v)) {
if slices.Contains(excludeNames, fileName) {
continue
}
var isDir bool
isDir, err = IsDirExists(v, false)
isDir, err = IsDirExists(file, false)
if err != nil {
return err
}

if isDir {
toPath := toPath + GetFileSeparator() + filepath.Base(v)
err = CopyDir(v, toPath, true, nil)
if err != nil {
return err
}
continue
err = CopyDir(file, filepath.Join(toPath, fileName), true, nil)
} else {
err = CopyFile(toPath, file)
}
err = CopyFile(toPath, v)
if err != nil {
return err
}
}
return err
return nil
}

func CopyFile(dst, src string) (err error) {
Expand Down

0 comments on commit 15c2382

Please sign in to comment.