[
https://issues.apache.org/jira/browse/SANDBOX-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597728#action_12597728
]
Eduardo Valentim commented on SANDBOX-196:
------------------------------------------
I have the same issue and fixed the problem in a similar way:
Index:
Compress/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java
===================================================================
--- Compress/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java
(revision 657025)
+++ Compress/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java
(working copy)
@@ -87,6 +87,15 @@
byte data[] = new byte[BUFFER];
String fosString = unpackDir.getAbsolutePath()
+ File.separator + entry.getName();
+
+ // The first files in zip format are
directories,
+ // then we need to create it
+ if (entry.isDirectory()) {
+ File fosFile = new File(fosString);
+ fosFile.mkdirs();
+ continue;
+ }
+
FileOutputStream fos = new
FileOutputStream(fosString);
destination = new BufferedOutputStream(fos,
BUFFER);
> Compress - ZipArchive - unpack() : IOException while unpacking due to missing
> directories
> -----------------------------------------------------------------------------------------
>
> Key: SANDBOX-196
> URL: https://issues.apache.org/jira/browse/SANDBOX-196
> Project: Commons Sandbox
> Issue Type: Bug
> Components: Compress
> Affects Versions: Nightly Builds
> Environment: Linux
> Java(TM) SE Runtime Environment (build 1.6.0-b105)
> Reporter: Christian Scheid
>
> In the current snapshot of the ZipArchive class of commons compress seems to
> be an OS/VM-related problem with the unpack() method of ZipArchive.
> I got an IOException using unpack() for a simple jar-archive.
> I figured out that the files from the ZipEntries couldn't be created because
> of missing parent directories.
> I fixed the problem by including the usage of the forceMkdir() of the
> commons-io FileUtils class in the unpack() method. In case you want to use my
> fix:
> // ... for every entry
> File outFile = new File(fosString);
> if (outFile.getParentFile() != null && !outFile.getParentFile().exists()) {
> FileUtils.forceMkdir(outFile.getParentFile());
> }
> FileOutputStream fos = new FileOutputStream(outFile);
> // ... write to filestream
> best regards,
> chris
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.