Uses a file chooser to define the zip file path. @return empty List to fill with files to be zipped
()
| 377 | * @return empty List<File> to fill with files to be zipped |
| 378 | */ |
| 379 | private ArrayList<File> defineZipFilePath() { |
| 380 | // show file chooser to get directory and zip name |
| 381 | AsyncFileChooser chooser = getFileChooser(); |
| 382 | int result = chooser.showSaveDialog(frame); |
| 383 | if (result != JFileChooser.APPROVE_OPTION) { |
| 384 | return null; |
| 385 | } |
| 386 | File chooserFile = chooser.getSelectedFile(); |
| 387 | if (chooserFile.exists()) { |
| 388 | // TODO: warn or cancel |
| 389 | } |
| 390 | if (!VideoIO.canWrite(chooserFile)) { |
| 391 | return null; |
| 392 | } |
| 393 | |
| 394 | // define zipFilePath and check for reserved characters, including spaces |
| 395 | zipFilePath = chooserFile.getAbsolutePath(); |
| 396 | String ext = XML.getExtension(chooserFile.getName()); |
| 397 | |
| 398 | // check for duplicate file if target extension not used |
| 399 | if (!"zip".equalsIgnoreCase(ext)) { |
| 400 | String newFilePath = XML.stripExtension(zipFilePath) + ".zip"; |
| 401 | if (!VideoIO.canWrite(new File(newFilePath))) |
| 402 | return null; |
| 403 | zipFilePath = newFilePath; |
| 404 | } |
| 405 | |
| 406 | // return empty list |
| 407 | return new ArrayList<File>() { |
| 408 | @Override |
| 409 | public boolean add(File f) { |
| 410 | if (!contains(f)) |
| 411 | super.add(f); |
| 412 | return true; |
| 413 | } |
| 414 | }; |
| 415 | } |
| 416 | |
| 417 | private AsyncFileChooser getFileChooser() { |
| 418 | if (fileChooser == null) { |
no test coverage detected