Setting Permissions in ZipArchive

I have a zip file. I open it using the ZipArchive php library and add the directory and file to it. When I retrieve it with the default unarchiver of Ubuntu, everything works as expected. But when I retrieve it with any unarchiver on OS X Snow Leopard (using Keka and The Unarchiver by default), the new permissions for the directory are 700. Expected permissions are 755.

So here is the original zip:

DIRECTORY
a.txt
b.txt

Here is my code:

<?php
$file = 'example.zip';
$zip = new ZipArchive;
$res = $zip->open($file, ZipArchive::CREATE);
  if ($res === TRUE) {

    $zip->addEmptyDir('DIRECTORY/NEW_DIR');
    $zip->addFromString('DIRECTORY/NEW_DIR/c.txt', 'hellooo');
    $zip->close();
  }
  else {
    print 'error';
  }

And the result:

DIRECTORY -> NEW_DIR -> c.txt
a.txt
b.txt

which is true, but the permissions of the NEW_DIR directory are 700 (drwx ------) instead of 755 if I extract it under osx. How to fix it?

Thank!

EDIT:

Here's the zipinfo about the files in my zip:

$ zipinfo -l test.zip 
(..)
drwxr-xr-x  3.0 unx        0 bx        0 stor 13-Dec-11 17:43 DIRECTORY/
-rw-r--r--  3.0 unx      533 tx      327 defN  3-Nov-11 01:50 a.txt
-rw-r--r--  3.0 unx    91669 tx    32044 defN  3-Nov-11 01:09 b.txt
-rw----     0.0 fat        0 b-        2 defN 13-Dec-11 18:12 DIRECTORY/new_dir/
-rw----     0.0 fat        7 b-        9 defN 14-Dec-11 10:30 DIRECTORY/new_dir/c.txt
+5
source share
1

, -

<?php
    exec("chmod -R 755 /directory/new_dir");
-1

All Articles