incompatible ZIP format ??

Support for Android version of Total Commander

Moderators: sheep, Hacker, Stefan2, white

Post Reply
t_arn
Junior Member
Junior Member
Posts: 38
Joined: 2006-12-28, 07:52 UTC

incompatible ZIP format ??

Post by *t_arn »

I used TCrc3 and created a ZIP with files and subdirs and then got a "data error" exception when I tried to extract the ZIP again with JavaIDEdroid. The error occurs when extracting an empty subdirectory.

When I create the same ZIP with TotalCommander on Windows or with ASTRO on Android, everything works fine.

Here's the code I use in JavaIDEdroid to extract the ZIP:

Code: Select all

  
public String createStructureFromTemplate (String prjdir)
  {
    int n;
    boolean ok;
    File d, newFile;
    byte[] buf = new byte[1024];
    ZipInputStream zipinputstream = null;
    FileOutputStream fileoutputstream;
    ZipEntry zipentry;
    String filename = G.stWorkDir+"project-template.zip";
    String errmsg="";
    
    try
    {
      d = new File(prjdir);
      if (d.exists()) return "target dir already exists";
      ok = d.mkdirs();
      if (!ok) return "error creating target dir";
      zipinputstream = new ZipInputStream(new FileInputStream(filename));
      zipentry = zipinputstream.getNextEntry();
      while (zipentry != null) 
      { 
        //for each entry to be extracted
         String entryName = zipentry.getName();
         newFile = new File(prjdir+entryName);
         if (zipentry.isDirectory())
         {
           newFile.mkdirs();
         }
         else
         {
           d = newFile.getParentFile();
           if (!d.isDirectory()) d.mkdirs();
           fileoutputstream = new FileOutputStream(newFile);             
           while ((n = zipinputstream.read(buf, 0, 1024)) > -1)
           {
             fileoutputstream.write(buf, 0, n);
           }//while
           fileoutputstream.close(); 
           zipinputstream.closeEntry();
         }//if
         zipentry = zipinputstream.getNextEntry();
      }//while
      zipinputstream.close();
    }//try
    catch (Throwable t)
    {
      errmsg=t.getMessage();
    }
    return errmsg;
  }
Is the ZIP format created by TCrc3 in some way different from the Windows version ?

Tom

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 39712
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No, not to my knowledge. Can you pack the same empty directory with TC and some other program, and then send me the two files?
Author of Total Commander
http://www.ghisler.com

t_arn
Junior Member
Junior Member
Posts: 38
Joined: 2006-12-28, 07:52 UTC

Post by *t_arn »

I have sent you the two ZIPs - the one from TCrc3 (NOK.zip) and one that works (OK.zip)

Tom

Post Reply