(
clone bool,
srcBase, dstBase string,
copyRelPath, skipErrors bool,
excludePatterns []string, ignoreDirNames, ignoreFileNames map[string]struct{},
errs *[]error)
| 809 | } |
| 810 | |
| 811 | func copyFileObjectHandler( |
| 812 | clone bool, |
| 813 | srcBase, dstBase string, |
| 814 | copyRelPath, skipErrors bool, |
| 815 | excludePatterns []string, ignoreDirNames, ignoreFileNames map[string]struct{}, |
| 816 | errs *[]error) filepath.WalkFunc { |
| 817 | var foCount uint64 |
| 818 | |
| 819 | return func(path string, info os.FileInfo, err error) error { |
| 820 | foCount++ |
| 821 | |
| 822 | if err != nil { |
| 823 | |
| 824 | if skipErrors { |
| 825 | *errs = append(*errs, err) |
| 826 | return nil |
| 827 | } |
| 828 | |
| 829 | return err |
| 830 | } |
| 831 | |
| 832 | foBase := filepath.Base(path) |
| 833 | |
| 834 | var isIgnored bool |
| 835 | for _, xpattern := range excludePatterns { |
| 836 | found, err := doublestar.Match(xpattern, path) |
| 837 | if err != nil { |
| 838 | log.Warnf("copyFileObjectHandler - [%v] excludePatterns Match error - %v\n", path, err) |
| 839 | //should only happen when the pattern is malformed |
| 840 | continue |
| 841 | } |
| 842 | if found { |
| 843 | isIgnored = true |
| 844 | break |
| 845 | } |
| 846 | } |
| 847 | /* |
| 848 | if _, ok := ignorePaths[path]; ok { |
| 849 | isIgnored = true |
| 850 | } |
| 851 | |
| 852 | for prefix := range ignorePrefixes { |
| 853 | if strings.HasPrefix(path, prefix) { |
| 854 | isIgnored = true |
| 855 | break |
| 856 | } |
| 857 | } |
| 858 | */ |
| 859 | |
| 860 | var targetPath string |
| 861 | if copyRelPath { |
| 862 | targetPath = filepath.Join(dstBase, strings.TrimPrefix(path, srcBase)) |
| 863 | } else { |
| 864 | targetPath = filepath.Join(dstBase, path) |
| 865 | } |
| 866 | |
| 867 | switch { |
| 868 | case info.Mode().IsDir(): |
no test coverage detected