(binTypeFiles []*fileConfig)
| 209 | } |
| 210 | |
| 211 | func copyBinFiles(binTypeFiles []*fileConfig) { |
| 212 | for _, binFile := range binTypeFiles { |
| 213 | source := binFile.source |
| 214 | dest := binFile.destination |
| 215 | |
| 216 | // create dir |
| 217 | outputDirPath, _ := path.Split(dest) |
| 218 | err := fs.CreateDirs(outputDirPath) |
| 219 | if err != nil { |
| 220 | flog.Errorf("Error creating directory '%s': %v", source, err) |
| 221 | } |
| 222 | |
| 223 | // create refs to src and dest |
| 224 | from, err := os.Open(source) |
| 225 | if err != nil { |
| 226 | flog.Errorf("Error opening file to read '%s' : %v", source, err) |
| 227 | } |
| 228 | defer from.Close() |
| 229 | |
| 230 | to, err := os.OpenFile(dest, os.O_RDWR|os.O_CREATE, binFile.modeBits) |
| 231 | if err != nil { |
| 232 | log.Fatal(err) |
| 233 | flog.Errorf("Error creating file '%s': %v", dest, err) |
| 234 | } |
| 235 | defer to.Close() |
| 236 | |
| 237 | // copy file |
| 238 | _, err = io.Copy(to, from) |
| 239 | if err != nil { |
| 240 | flog.Errorf("Error copying file '%s' : %v", source, err) |
| 241 | } else { |
| 242 | flog.Successf("Finished copying file : %s", dest) |
| 243 | } |
| 244 | } |
| 245 | } |
no test coverage detected