473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

unzipping while preserving permissions

Hi,

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,
$unzip_dir)
{
$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

Nov 21 '06 #1
1 1801
On 21 Nov 2006 09:06:13 -0800, "la***********@zipmail.com"
<la***********@zipmail.comwrote:
>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,
$unzip_dir)
{
$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
What's your umask currently set to?

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

"
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 :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Karl | last post by:
This might not really be a javascript question, but I'll start with this group. At http://www.gazingus.org/ there is a very nice collapsible menu written using CSS and Javascript >>>> Using...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
7
by: thewhoracle | last post by:
I have a C# application that essentially builds batch and text files and runs them from the command line, but i need to unzip something from the command line. What i need is either an unzipping...
0
by: stjulian | last post by:
On Windows Server 2003, IIS 6 I am looking for an unzipping component. I have a series of files that are available zipped at a considerable decrease in size. And before ASPINET fails on a script...
1
by: Andrew Koenig | last post by:
The answer to this question probably involves pywin32 or a similar library. I would like to copy a file from one place to another on a Windows machine while preserving as much of the file...
0
by: avik1612 | last post by:
Hi, I have created a program to unzip the file. It is unzipping the zip files when put in directory i.e folder inside folder but when i create a zip file without putting in a folder and try to...
3
by: sophia.agnes | last post by:
Dear all, I was going through the book "C a software engineering approach by darnell & Margolis" there was a section named sign preserving vs value preserving it is as follows sign...
1
by: kss | last post by:
Hey all, I am new to python and I need to unzip a zip file which is password protected. I tried using zipfile class. Aparently, when i try doing a zip.read(filename), it throws an exception stating...
1
by: deepakd | last post by:
Hi I'm using wxZipInputStream for unzipping a zipped ".app" file in MAC OS.After unzipping i am not able to run the app.When i manually copy the unix executable to app packages, I am able to run...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.