You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Casi Colada (JIRA)" <ji...@apache.org> on 2016/10/04 15:53:20 UTC

[jira] [Created] (COMPRESS-366) TarArchiveEntry: getDirectoryEntries not working

Casi Colada created COMPRESS-366:
------------------------------------

             Summary: TarArchiveEntry: getDirectoryEntries not working
                 Key: COMPRESS-366
                 URL: https://issues.apache.org/jira/browse/COMPRESS-366
             Project: Commons Compress
          Issue Type: Bug
          Components: Archivers
    Affects Versions: 1.12
         Environment: Eclipse 4.6, Linux 64 Bit
            Reporter: Casi Colada
            Priority: Minor


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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)