This would appear to be a bug.

I create a zip file using ZipOutputStream with success.
I can then transfer it from the tablet to my PC and look at it with WinZip.
All files have the corresponding size, compressed size, and CRC values.

Now, if I open the zip with ZipInputStream and call getNextEntry, these 
values are not set.
Here is how I am reading the file :

try
{
    // open the archive
    FileInputStream fis = new FileInputStream(fArchive);
    ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
    bBuffer = new byte[2048];

    // iterate through all files, putting them back into the same place
    ze = zis.getNextEntry();
    while(ze != null)
    {
        strFileName = ze.getName();
        strFileName = FILE_PATH + "/" + strFileName;
        fCheck = new File(strFileName);
        lZipFileSize = ze.getSize(); // <--- returns -1 systematically
        lTargetFileSize = fCheck.length();
        fCheck = null;
        FileOutputStream fos = new FileOutputStream(strFileName);

        // read the data
        while((iCount = zis.read(bBuffer)) != -1)
        {
            fos.write(bBuffer, 0, iCount);
        }
        fos.close();

        ze = zis.getNextEntry();
    }
    zis.close();
    fis.close();
    bOk = true;
}
catch(Exception e)
{
    e.printStackTrace();
}


When I look into the source for ZipInputStream, I see the following code :
if (!hasDD) {
    ceCrc = ((long) Memory.peekInt(hdrBuf, LOCCRC - LOCVER, ByteOrder.
LITTLE_ENDIAN)) & 0xffffffffL;
    ceCompressedSize = ((long) Memory.peekInt(hdrBuf, LOCSIZ - LOCVER, 
ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL;
    ceSize = ((long) Memory.peekInt(hdrBuf, LOCLEN - LOCVER, ByteOrder.
LITTLE_ENDIAN)) & 0xffffffffL;
}

This is the only position that I can see where the values are retrieved, 
yet it is ignored because of the !hasDD condition.

Have I misunderstood something here ?
Is this a real bug or is there an extra step to be taken ?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/e76679a5-d150-4657-85fd-85db8fdad45f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to