cpDir copies the contents of src dir into dst dir. filter is a list of file suffixes to skip. ex: ".go"
(src, dst string, filter []string)
| 73 | // cpDir copies the contents of src dir into dst dir. |
| 74 | // filter is a list of file suffixes to skip. ex: ".go" |
| 75 | func cpDir(src, dst string, filter []string) error { |
| 76 | return filepath.Walk(src, func(fullpath string, fi os.FileInfo, err error) error { |
| 77 | if err != nil { |
| 78 | return err |
| 79 | } |
| 80 | for _, suffix := range filter { |
| 81 | if strings.HasSuffix(fi.Name(), suffix) { |
| 82 | return nil |
| 83 | } |
| 84 | } |
| 85 | suffix, err := filepath.Rel(src, fullpath) |
| 86 | if err != nil { |
| 87 | return fmt.Errorf("Failed to find Rel(%q, %q): %v", src, fullpath, err) |
| 88 | } |
| 89 | if fi.IsDir() { |
| 90 | return nil |
| 91 | } |
| 92 | return cpFile(fullpath, filepath.Join(dst, suffix)) |
| 93 | }) |
| 94 | } |
| 95 | |
| 96 | func cpFile(src, dst string) error { |
| 97 | sfi, err := os.Stat(src) |
no test coverage detected