* @return The number of entries extracted.
*/
private int unZapTarFile(File fileToUnzap, String fileToUnzapLowerCase) {
InputStream is = null;
TarInputStream tis = null;
TarEntry tarEntry = null;
boolean entryFound = false;
boolean nonDirectoryEntryFound = false;
int numberEntriesExtracted = 0;
try {
is = new FileInputStream(fileToUnzap);
// If the tar file ends with a Gzip extension, use the GZIP filter.
if ( fileToUnzapLowerCase.endsWith(this.tarGzipExtension) ||
fileToUnzapLowerCase.endsWith(this.tarGzipExtensionAlt1) ||
fileToUnzapLowerCase.endsWith(this.tarGzipExtensionAlt2) ) {
is = new GZIPInputStream(is);
}
tis = new TarInputStream(is);
String fileName = null;
// Loop through all the tar entries.
tarEntry = tis.getNextEntry();
while (tarEntry != null) {
entryFound = true;
// Skip over directories
if (!tarEntry.isDirectory()) {
nonDirectoryEntryFound = true;
// Should this file be should extracted?
if (this.nameSelector.isIncluded(tarEntry.getName())) {
fileName = makeOutputFileName(tarEntry.getName(), fileToUnzap.getName());
writeNextTarEntry(tis,
new File(this.destLocationFile, fileName));
numberEntriesExtracted++;
}
}
tarEntry = tis.getNextEntry();
}
// If no entries extracted, log message.
if (numberEntriesExtracted == 0) {
msgEntry.setAppContext("unZapTarFile()");