commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Casi Colada (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COMPRESS-366) TarArchiveEntry: getDirectoryEntries not working
Date Wed, 05 Oct 2016 09:04:21 GMT

    [ https://issues.apache.org/jira/browse/COMPRESS-366?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15548133#comment-15548133
] 

Casi Colada commented on COMPRESS-366:
--------------------------------------

Thank you very much. That was not clear to me after reading the Javadoc.

> 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
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> 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)

Mime
View raw message