rendered paste body public void export() throws ArchiveSaveFailureException {
IProgressMonitor subMonitor = new SubProgressMonitor(progressMonitor, EXPORT_WORK);
final int SAVE_TICKS = 198;
final int CLEANUP_TICKS = 2;
final int TOTAL_TICKS = SAVE_TICKS + CLEANUP_TICKS;
try {
File writeFile = getDestinationPath().toFile();
if (writeFile.exists()) {
writeFile.delete();
}
java.io.File aFile = getDestinationPath().toFile();
ArchiveUtil.checkWriteable(aFile);
boolean fileExisted = aFile.exists();
FlatComponentArchiver archiver = null;
try { // ******** this can throw an IOException
java.io.File destinationFile = fileExisted
? ArchiveUtil.createTempFile(getDestinationPath().toOSString(), aFile.getCanonicalFile().getParentFile())
: aFile;
java.io.OutputStream out = createOutputStream(destinationFile);
archiver = createFlatComponentArchiver(out);
subMonitor.beginTask(NLS.bind(CommonArchiveResourceHandler.ArchiveFactoryImpl_Saving_archive_to_0_, getDestinationPath().toOSString()), TOTAL_TICKS);
archiver.saveArchive();
subMonitor.worked(SAVE_TICKS);
archiver.close();
if (fileExisted) {
ArchiveUtil.cleanupAfterTempSave(getDestinationPath().toOSString(), aFile, destinationFile);
}
subMonitor.worked(CLEANUP_TICKS);
} catch (java.io.IOException e) {
throw new ArchiveSaveFailureException(e);
} catch (ArchiveSaveFailureException failure) {
try { // *** THIS IS ERRORING AS IMPOSSIBLE TO BE NULL
if (archiver != null)
archiver.close();
} catch (IOException weTried) {
// Ignore
}
if (!fileExisted)
aFile.delete();
throw failure;
}
} finally {
subMonitor.done();
}
}