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

TarArchiveEntry: getDirectoryEntries not working

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.12
    • Fix Version/s: 1.13
    • Component/s: Archivers
    • Labels:
      None
    • Environment:

      Eclipse 4.6, Linux 64 Bit

      Description

      TarArchiveEntry.getDirectoryEntries() always returns an empty array. This is because entry.getFile() returns null for a directory entry.

      Let folder.tar be a Tar Archive which contains a folder, and that folder contains a file. Consider the following snippet:


      import java.io.FileInputStream;
      import org.apache.commons.compress.archivers.tar.*;

      public class GetDirectoryEntriesBug {
      public static void main(String[] args) throws Exception {
      TarArchiveInputStream tais = new TarArchiveInputStream(new FileInputStream("folder.tar"));
      for(TarArchiveEntry entry; (entry = tais.getNextTarEntry()) != null; )

      { System.out.println("Name: " + entry.getName() + ", isDirectory: " + entry.isDirectory() + ", getDirectoryEntries().length: " + entry.getDirectoryEntries().length); }

      tais.close();
      }
      }


      Output:
      Name: folder/file, isDirectory: false, getDirectoryEntries().length: 0
      Name: folder/, isDirectory: true, getDirectoryEntries().length: 0

      I expected that, for "folder/", getDirectoryEntries() will not return an empty array.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              casi_colada Casi Colada
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified