MCPcopy Create free account
hub / github.com/PCGen/pcgen / createFiles

Method createFiles

code/src/java/pcgen/gui2/dialog/DataInstaller.java:606–630  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

installDataSourceMethod · 0.80

Calls 8

correctFileNameMethod · 0.95
isDebugModeMethod · 0.95
debugPrintMethod · 0.95
copyInputStreamMethod · 0.95
errorPrintMethod · 0.95
showMessageDialogMethod · 0.95
getFormattedStringMethod · 0.95
getEntryMethod · 0.80

Tested by

no test coverage detected