if(new File(lnxDirectory, "flashplayer.tar.gz").exists()) {
flashPlayerBinary = new File(lnxDirectory, "flashplayer.tar.gz");
} else if(new File(lnxDirectory, "flashplayerdebugger.tar.gz").exists()) {
flashPlayerBinary = new File(lnxDirectory, "flashplayerdebugger.tar.gz");
} else {
throw new ConverterException("Couldn't find player archive.");
}
// Decompress the archive.
// First unzip it.
final FileInputStream fin;
try {
fin = new FileInputStream(flashPlayerBinary);
final BufferedInputStream in = new BufferedInputStream(fin);
final File tempTarFile = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".tar");
final FileOutputStream out = new FileOutputStream(tempTarFile);
final GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
final byte[] buffer = new byte[1024];
int n;
while (-1 != (n = gzIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
gzIn.close();
// Then untar it.
File uncompressedBinary = null;
final FileInputStream tarFileInputStream = new FileInputStream(tempTarFile);
final TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(tarFileInputStream);
ArchiveEntry entry;
while((entry = tarArchiveInputStream.getNextEntry()) != null) {
if("flashplayer".equals(entry.getName())) {
uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
while(-1 != (n = tarArchiveInputStream.read(buffer))) {
uncompressedBinaryOutputStream.write(buffer, 0, n);
}
uncompressedBinaryOutputStream.close();
} else if("flashplayerdebugger".equals(entry.getName())) {
uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
while(-1 != (n = tarArchiveInputStream.read(buffer))) {
uncompressedBinaryOutputStream.write(buffer, 0, n);
}
uncompressedBinaryOutputStream.close();
}
}
tarFileInputStream.close();
// If a binary exists, copy it to the target and create a pom for it.
if (uncompressedBinary != null) {
playerArtifact.addBinaryArtifact("linux", flashPlayerBinary);
}
} catch (FileNotFoundException e) {
throw new ConverterException("Error processing the linux player tar file", e);
} catch (IOException e) {
throw new ConverterException("Error processing the linux player tar file", e);
}
}
// Write this artifact to file.
writeArtifact(playerArtifact);