// Set the streams up.
OutputStream outStream = new FileOutputStream(tarDestFile);
if (gzipIt) {
outStream = new GZIPOutputStream(outStream);
}
TarOutputStream tarOutStream = new TarOutputStream(outStream);
// Step through all of the files.
for (int i=0; i < fileHolder.selectedFileList.size(); i++){
File selectedFile = fileHolder.selectedFileList.get(i);
// This is set in case the manager kills the processor and
// wants to log the file that was being processed.
super.currentObjBeingProcessed = selectedFile;
// Instance variable used so the "cleanUp()" method can
// close this stream.
this.inStream = new FileInputStream(selectedFile);
TarEntry tarEntry = null;
try {
tarEntry = new TarEntry(selectedFile, selectedFile.getName());
} catch (InvalidHeaderException e) {
errEntry.setThrowable(e);
errEntry.setAppContext("tar()");
errEntry.setAppMessage("Error tar'ing: " + selectedFile);
logger.logError(errEntry);
}
tarOutStream.putNextEntry(tarEntry);
while((bytes_read = inStream.read(buffer)) != -1) {
tarOutStream.write(buffer,0,bytes_read);
}
tarOutStream.closeEntry();
inStream.close();
// Restart the wait period (so if the time to send a single
// file is too long the processor is killed).
super.processorSyncFlag.restartWaitUntilFalse();
}
tarOutStream.close();
} catch (Exception e) {
errEntry.setThrowable(e);
errEntry.setAppContext("tar()");
errEntry.setAppMessage("Error tar'ing: " + tarDestFile);