(sourceDirectory string, elementsPaths map[string]string, targetLocation string)
| 119 | } |
| 120 | |
| 121 | func copyContent(sourceDirectory string, elementsPaths map[string]string, targetLocation string) error { |
| 122 | for name, path := range elementsPaths { |
| 123 | if path != "" { |
| 124 | sourceLocation := filepath.Join(sourceDirectory, path) |
| 125 | filesInSourceInfo, err := os.Stat(sourceLocation) |
| 126 | if err != nil { |
| 127 | return fmt.Errorf("Error building MTA Archive: file path %s not found", sourceLocation) |
| 128 | } |
| 129 | destinationLocation := filepath.Join(targetLocation, name, filepath.Base(path)) |
| 130 | if filesInSourceInfo.IsDir() { |
| 131 | err = copyDirectory(sourceLocation, destinationLocation) |
| 132 | } else { |
| 133 | os.MkdirAll(filepath.Dir(destinationLocation), os.ModePerm) |
| 134 | err = copyFile(sourceLocation, destinationLocation) |
| 135 | } |
| 136 | if err != nil { |
| 137 | return err |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | func copyDirectory(src, dest string) error { |
| 145 | var err error |
no test coverage detected