Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-105

While Archiving the empty directories are not archived to the archive.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.1
    • None
    • None
    • 64 bit Windows Vista, JDK1.4.1_11

    Description

      I am trying to create a zip archive. I am having a empty directory "test" . When i try to create it to archive . The archive created but the test folder is created as file. And also I got the below exception.

      Temp file created at C:\Users\Soundar\AppData\Local\Temp\sample5278197872513888977.zip
      Exception in thread "main" java.io.IOException: This archives contains unclosed entries.
      at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.finish(ZipArchiveOutputStream.java:343)
      at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.close(ZipArchiveOutputStream.java:550)
      at com.tcs.tools.archive.test.ArchiveTest.createArchive(ArchiveTest.java:64)
      at com.tcs.tools.archive.test.ArchiveTest.main(ArchiveTest.java:119)

      Code used
      -------------

      protected File createArchive(String archivename) throws Exception {
      ArchiveOutputStream out = null;
      OutputStream stream = null;
      ArchiveStreamFactory factory = new ArchiveStreamFactory();
      try

      { File archive = File.createTempFile("sample", "." + archivename); System.out.println("Temp file created at " + archive.getAbsolutePath()); List archiveList = new ArrayList(); stream = new FileOutputStream(archive); out = factory.createArchiveOutputStream(archivename, stream); final File file7 = new File("C:\\Users\\Soundar\\Desktop\\test"); addArchiveEntry(out, "test", file7); System.out.println("Going to process directory"); System.out.println("Directory Name =" + file7.getName()); ArchiveEntry entry = out.createArchiveEntry(file7, "test"); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file7), out); out.closeArchiveEntry(); out.finish(); return archive; }

      finally {
      if (out != null)

      { out.close(); }

      else if (stream != null)

      { stream.close(); }

      }
      }

      Note
      ------

      I tried the same archiving using the compressed zip of Windows Vista default feature. It creates the Sample.zip which contains the empty test folder as archived.

      I know there is a work around using java.util.zip.zipEntry. But is there a work around in our Compress itself?

      Attachments

        1. ArchiveIssue.JPG
          78 kB
          Soundararajan Thevaraj
        2. TestDirectory.java
          4 kB
          Soundararajan Thevaraj

        Activity

          People

            Unassigned Unassigned
            soundararajan@jira Soundararajan Thevaraj
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: