Creates the files in the archive, as filtered by previous user actions. @param dataSet the data set (campaign) to be installed. @param destDir the destination data directory @param files the list of file names @return true, if all files created ok
(File dataSet, File destDir, Iterable<String> files)
| 604 | * @return true, if all files created ok |
| 605 | */ |
| 606 | private static boolean createFiles(File dataSet, File destDir, Iterable<String> files) |
| 607 | { |
| 608 | String corrFilename = ""; |
| 609 | try (ZipFile in = new ZipFile(dataSet)) |
| 610 | { |
| 611 | for (String filename : files) |
| 612 | { |
| 613 | ZipEntry entry = in.getEntry(filename); |
| 614 | corrFilename = correctFileName(destDir, filename); |
| 615 | if (Logging.isDebugMode()) |
| 616 | { |
| 617 | Logging.debugPrint("Extracting file: " + filename + " to " + corrFilename); |
| 618 | } |
| 619 | copyInputStream(in.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(corrFilename))); |
| 620 | } |
| 621 | return true; |
| 622 | } catch (IOException e) |
| 623 | { |
| 624 | // Report the error |
| 625 | Logging.errorPrint("Failed to read data set " + dataSet + " or write file " + corrFilename + " due to ", e); |
| 626 | ShowMessageDelegate.showMessageDialog(LanguageBundle.getFormattedString("in_diWriteFail", corrFilename), |
| 627 | TITLE, MessageType.ERROR); |
| 628 | return false; |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | /** |
| 633 | * Build the user interface ready for display. |
no test coverage detected