ensured subdirectories are built while extracting tar files - issue #43

Former-commit-id: af8b794ed9be453e2aad6807e238826468cc5d3e
This commit is contained in:
Jeremy Long
2014-01-20 12:48:47 -05:00
parent 1c3b5e75d2
commit be5a6f7e7d

View File

@@ -295,7 +295,7 @@ public class ArchiveAnalyzer extends AbstractAnalyzer implements Analyzer {
final File d = new File(destination, entry.getName());
if (!d.exists()) {
if (!d.mkdirs()) {
final String msg = String.format("Unable to create '%s'.", d.getAbsolutePath());
final String msg = String.format("Unable to create directory '%s'.", d.getAbsolutePath());
throw new AnalysisException(msg);
}
}
@@ -306,6 +306,13 @@ public class ArchiveAnalyzer extends AbstractAnalyzer implements Analyzer {
BufferedOutputStream bos = null;
FileOutputStream fos;
try {
File parent = file.getParentFile();
if (!parent.isDirectory()) {
if (!parent.mkdirs()) {
final String msg = String.format("Unable to build directory '%s'.", parent.getAbsolutePath());
throw new AnalysisException(msg);
}
}
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos, BUFFER_SIZE);
int count;