Adds files to the zip list @param zipList the list of files to be zipped
(ArrayList<File> zipList)
| 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) { |
no test coverage detected