MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / prepareZipFiles

Method prepareZipFiles

src/test/LoaderTest.java:450–492  ·  view source on GitHub ↗

Adds files to the zip list @param zipList the list of files to be zipped

(ArrayList<File> zipList)

Source from the content-addressed store, hash-verified

448 * @param zipList the list of files to be zipped
449 */
450 private boolean prepareZipFiles(ArrayList<File> zipList) {
451
452 String tmpDir = getTempDirectory();
453 // save edited file and add to the list
454 int n = editedFilePath.indexOf("!");
455 if (n == -1)
456 return false;
457 String subPath = editedFilePath.substring(n+2, editedFilePath.length());
458 File targetFile = new File(tmpDir, subPath);
459 targetFile = saveEditorTextTo(targetFile);
460 if (targetFile == null || !targetFile.exists())
461 return false;
462 zipList.add(targetFile);
463
464 for (String path : xmlFiles) {
465 n = path.indexOf("!");
466 if (n == -1)
467 return false;
468 subPath = path.substring(n+2, path.length());
469 targetFile = new File(tmpDir, subPath);
470 if (!(targetFile.getParentFile().exists() || targetFile.getParentFile().mkdirs()))
471 return false;
472 targetFile = ResourceLoader.extract(path, targetFile);
473 if (!targetFile.exists())
474 return false;
475 zipList.add(targetFile);
476 }
477
478 for (String path : otherFiles) {
479 n = path.indexOf("!");
480 if (n == -1)
481 return false;
482 subPath = path.substring(n+2, path.length());
483 targetFile = new File(tmpDir, subPath);
484 if (!(targetFile.getParentFile().exists() || targetFile.getParentFile().mkdirs()))
485 return false;
486 targetFile = ResourceLoader.extract(path, targetFile);
487 if (!targetFile.exists())
488 return false;
489 zipList.add(targetFile);
490 }
491 return true;
492 }
493
494 private String getTempDirectory() {
495 if (tempDir == null) {

Callers 1

saveNewZipMethod · 0.95

Calls 6

getTempDirectoryMethod · 0.95
saveEditorTextToMethod · 0.95
extractMethod · 0.95
lengthMethod · 0.80
existsMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected