#40 file permision in Android platform

v1.0_(example)
closed-out-of-date
nobody
None
3
2014-08-15
2013-10-06
along
No

If you create a .zip file in Android platform, the file permision is NULL, if you uncompress the .zip file use some old zip uncompress program(szip), the file permision is wrong . It result file open error(in my computer, OGR driver can't open .shp file because the file permision is NULL).
I modify the zip.c as follow: in zipOpenNewFileInZip3 function

if (zipfi==NULL)
    ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0x81b60020,4);
else
    ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);

why 0x81b60020 ?
Because in quazipfileinfo.cpp

quint32 uPerm = (externalAttr & 0xFFFF0000u) >> 16;

uPerm 's value means 666 .

Discussion

  • Sergey A. Tachenov

    I don't get it. That line wouldn't be executed anyway since QuaZIP always passes a non-NULL zipfi argument. Instead, you should just set the external attributes when opening a new file, possibly using the convenient wrapper QuaZipNewInfo::setPermissions(). No need to change QuaZIP code for that.

     
  • Sergey A. Tachenov

    • status: open --> pending-works-for-me
     
  • along

    along - 2013-10-08

    This bug is the same as bug#34 Quazip doesn't save file permissions.
    My problem occurs on Android platform. I also try it on Ubuntu12.04, but it's OK, QuaZIP can read file permision and set right permision.
    I don't know why it set file permision to NULL on Android platform.
    Maybe zipfi==NULL or zipfi->external_fa==NULL .
    I didn't test it. But I'm sure the file permision in zip is NULL.

     
  • Sergey A. Tachenov

    OK, first off, permissions can't be NULL. They can be zero.

    zipfi can't be null because QuaZIP always passes a structure there, which it makes from the supplied QuaZipNewInfo object.

    Now, zipfi->external_fa CAN be 0 because it's copied from the QuaZipNewInfo.externalAttr, which you can initialized to anything, including 0. BUT if you use the two-argument constructor, it takes file permissions from the file you supply as the second argument, assuming that file EXISTS and that its permissions are available to Qt (which they should be, but who knows?). If the file permissions are unavailable, then they will be set to 0. If that happens, it's a problem, and possibly a bug, but not a bug in QuaZIP - it just takes whatever QFileInfo::permissions() returns.

    But even if the externalAttr is 0, and there's something wrong with permissions on a particular platform (Android), you still can set permissions manually, using QuaZipNewInfo::setPermissions(). This way you completely avoid relying on whatever Qt reports to QuaZIP.

    TL;DR: QuaZIP uses permissions returned by QFileInfo::permissions() if you use the QuaZipNewInfo constructor with two arguments, but even if it fails (which isn't QuaZIP's fault), you can always use QuaZipNewInfo::setPermissions() or even set QuaZipNewInfo.externalAttr directly.

     
  • along

    along - 2013-10-09

    Thanks!
    I just use JlCompress::compressDir(resultZip, dir) to compress a dir to .zip file. I don't think QuaZipNewInfo::setPermissions() is helpful for this.
    Maybe the permissions=0 because files are in /sdcard, the file system is fat32, there is no file permission on it and QT return 0.

     
  • along

    along - 2013-10-09

    I debug my program in Android and find the quazip I used is an old version. external_fa is initialized to 0.

     
  • Sergey A. Tachenov

    Oh, yes, JlCompress::compressDir() just uses the two-argument constructor that takes permissions from the file. Unless your version is old enough to have the bug #34, in which case you'll get 0 indeed.

    I'm not sure about sdcards. Even if it's fat32, the OS should return some "basic" permissions for every file there (usually specified when mounting). Otherwise it would break a lot of software, not just QuaZIP.

    You should really update QuaZIP to the latest version if possible. Preferably, use the SVN trunk since the last release is pretty old now.

     
    • along

      along - 2013-11-26

      The reason for my mis-use old version quazip is I didn't find the version number in old version quazip files. Shell we add the version number in ReadMe.txt or some other files to prevent the same stupid mistakes like mine? ^_^

       
  • Sergey A. Tachenov

    It's a pain to maintain. The version is already included in the directory name (like quazip-0.5) and the Doxygen docs, not to mention the NEWS.txt. I don't want yet another place to remember to modify during the version update process.

     
  • Sergey A. Tachenov

    • status: pending-works-for-me --> closed-out-of-date
     

Log in to post a comment.