unzipping while preserving permissions

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm using PHP 4.4.4 with Apache 2 on Linux.  I have a PHP function to
unzip a file, but I would like the resulting unzipped file with all its
sub-directories and files to have the same permissions as the parent
file, or at least 755 perms.  Right now, it is being created with
rw-r--r-- perms.  Here is my function

        function unzipFile($p_zip_file_path, $p_zip_file_pwd,
                $cmd = "unzip ";
                if (!empty($p_zip_file_pwd)) {
                        $cmd .= " -P $p_zip_file_pwd ";
                }   //
                $cmd .= " -o -d $unzip_dir $p_zip_file_path 2>&1";
                exec($cmd, $output, $return);
                // failed if non-zero
                if ($return != 0) {
                        $output = join("<BR>\n", $output) . "<BR>\n";
                        return $output;
                }   // if
                return "";

Any suggestions on how to modify it?  Thanks, - Dave

Re: unzipping while preserving permissions

On 21 Nov 2006 09:06:13 -0800, "laredotornado@zipmail.com"

Quoted text here. Click to load it

 What's your umask currently set to?

 Do the files have permissions in the original zip file? The "unzip" man page

       Dates, times and permissions of stored directories are not restored
except under Unix. (On Windows NT
       and successors, timestamps are now restored.)

 ... which implies that the contents of the zip may influence the permissions.

 You could also reset the permissions after extraction, if umask isn't the key.

Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Site Timeline