/** * Optimizes the given writable archive file and notifies the user in case of an error. * * @param rwArchiveFile the writable archive file to optimize */ protected void optimizeArchive(AbstractRWArchiveFile rwArchiveFile) { isOptimizingArchive = true; while(true) { try { archiveToOptimize = rwArchiveFile; archiveToOptimize.optimizeArchive(); break; } catch(IOException e) { if(showErrorDialog(errorDialogTitle, Translator.get("error_while_optimizing_archive", rwArchiveFile.getName()))==FileJobAction.RETRY) continue; break; } } isOptimizingArchive = false; }
/** * Updates this entry's attributes in the archive and returns <code>true</code> if the update went OK. * * @return <code>true</code> if the attributes were successfully updated in the archive. */ private boolean updateEntryAttributes() { try { ((AbstractRWArchiveFile)archiveFile).updateEntry(entry); return true; } catch(IOException e) { return false; } }
ArchiveEntryTree tree = rwArchiveFile.getArchiveEntryTree(); if(tree!=null) { DefaultMutableTreeNode node = tree.findEntryNode(entry.getPath()); rwArchiveFile.deleteEntry(entry);
@Override public String getStatusString() { if(isOptimizingArchive) return Translator.get("optimizing_archive", archiveToOptimize.getName()); return Translator.get("delete.deleting_file", getCurrentFilename()); } }
/** * Creates this entry as a directory in the associated <code>AbstractArchiveFile</code>. * <p> * Throws a {@link UnsupportedFileOperationException} if if the underlying file does not support the required * read and write {@link FileOperation file operations}. Throws an <code>IOException</code> if this entry * already exists in the archive or if an I/O error occurred. * </p> * * @throws IOException if this entry already exists in the archive or if an I/O error occurred. * @throws UnsupportedFileOperationException if the underlying archive file does not support the required read and * write {@link FileOperation file operations}. */ @Override public void mkdir() throws IOException, UnsupportedFileOperationException { if(entry.exists()) throw new IOException(); AbstractRWArchiveFile rwArchivefile = (AbstractRWArchiveFile)archiveFile; // Update the ArchiveEntry entry.setDirectory(true); entry.setDate(System.currentTimeMillis()); entry.setSize(0); // Add the entry to the archive file rwArchivefile.addEntry(entry); // The entry now exists entry.setExists(true); }
@Override protected void jobCompleted() { super.jobCompleted(); // If the source files are located inside an archive, optimize the archive file AbstractArchiveFile archiveFile = getBaseSourceFolder().getParentArchive(); if(archiveFile!=null && archiveFile.isArchive() && archiveFile.isWritable()) { while(true) { try { archiveToOptimize = ((AbstractRWArchiveFile)archiveFile); isOptimizingArchive = true; archiveToOptimize.optimizeArchive(); break; } catch(IOException e) { if(showErrorDialog(errorDialogTitle, Translator.get("error_while_optimizing_archive", archiveFile.getName()))==FileJobAction.RETRY) continue; break; } } isOptimizingArchive = true; } }
@Override public String getStatusString() { if(isCheckingIntegrity()) return super.getStatusString(); if(isOptimizingArchive) return Translator.get("optimizing_archive", archiveToOptimize.getName()); return Translator.get("move_dialog.moving_file", getCurrentFilename()); } }
OutputStream out = new CounterOutputStream(((AbstractRWArchiveFile)archiveFile).addEntry(entry), new ByteCounter() { @Override
@Override public String getStatusString() { if(isCheckingIntegrity()) return super.getStatusString(); if(isOptimizingArchive) return Translator.get("optimizing_archive", archiveToOptimize.getName()); return Translator.get(mode==TransferMode.DOWNLOAD?"download_dialog.downloading_file":"copy_dialog.copying_file", getCurrentFilename()); } }
@Override public String getStatusString() { if(isCheckingIntegrity()) return super.getStatusString(); if(isOptimizingArchive) return Translator.get("optimizing_archive", archiveToOptimize.getName()); return Translator.get("unpack_dialog.unpacking_file", getCurrentFilename()); }