commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristina Chodorow <kchodo...@google.com>
Subject [compress] Getting external attributes from a ZipArchiveEntry
Date Wed, 10 Jun 2015 14:08:40 GMT
ZipArchiveEntry.getExternalAttributes() is always returning 0 for me.  I
have pasted a hex dump of the zip file I'm testing with at the bottom of
email: 2 files of 0 bytes, one named x and one named y.  Both of their
external attributes are 33184 (a081 in the hex dump).  However, running the
following program gives me 0 for both of their external attributes:

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;

public class Foo {
  public static void main(String args[]) throws IOException {
    File archiveFile = new File("myzip.zip");
    try (InputStream is = new FileInputStream(archiveFile)) {
      ZipArchiveInputStream in = new ZipArchiveInputStream(is);
      ZipArchiveEntry entry = in.getNextZipEntry();
      while (entry != null) {
        System.out.println("entry: " + entry);
        System.out.println("external: " + entry.getExternalAttributes());
        entry = in.getNextZipEntry();
      }
    }
  }
}

Do I need to do something different to get the external attributes?  Is
this a bug?

Hex dump of myzip.zip:

87654321  0011 2233 4455 6677 8899 aabb ccdd eeff  0123456789abcdef


00000000: 504b 0304 0a00 0000 0000 c766 c946 0000  PK.........f.F..
00000010: 0000 0000 0000 0000 0000 0100 1c00 7855  ..............xU
00000020: 5409 0003 361a 7733 441a 7755 7578 0b00  T...6.w3D.wUux..
00000030: 0104 2c03 0300 0488 1300 0050 4b03 040a  ..,........PK...
00000040: 0000 0000 00c7 66c9 4600 0000 0000 0000  ......f.F.......
00000050: 0000 0000 0001 001c 0079 5554 0900 0336  .........yUT...6
00000060: 1a77 5544 1a77 5575 780b 0001 042c 0303  .wUD.wUux....,..
00000070: 0004 8813 0000 504b 0102 1e03 0a00 0000  ......PK........
00000080: 0000 c766 c946 0000 0000 0000 0000 0000  ...f.F..........
00000090: 0000 0100 1800 0000 0000 0000 0000 a081  ................
000000a0: 0000 0000 7855 5405 0003 361a 7755 7578  ....xUT...6.wUux
000000b0: 0b00 0104 2c03 0300 0488 1300 0050 4b01  ....,........PK.
000000c0: 021e 030a 0000 0000 00c7 66c9 4600 0000  ..........f.F...
000000d0: 0000 0000 0000 0000 0001 0018 0000 0000  ................
000000e0: 0000 0000 00a0 813b 0000 0079 5554 0500  .......;...yUT..
000000f0: 0336 1a77 5575 780b 0001 042c 0303 0004  .6.wUux....,....
00000100: 8813 0000 504b 0506 0000 0000 0200 0200  ....PK..........
00000110: 8e00 0000 7600 0000 0000                 ....v.....

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message