Hello,

In order to get the filenames from the output below I have tried the following:

preg_match_all('/inflating:"(.*?)"/', $stdout, $matches);
print_r($matches);
return $matches[1];

But I only get empty arrays with it.

I need to fix that so I can have the filenames stored on arrays and also evaluate the type of output according to
the situations ilustrated bellow.


Contents of $stdout:

unzip test.zip
Archive:  test.zip
inflating: arch1.txt
inflating: arch2.txt
inflating: arch3.txt
inflating: arch4.txt
inflating: arch5.txt
inflating: arch6.txt

The same I have from a pkware execution :

pkunzip teste.zip
PKZIP(R)  Version 6.0  FAST!  Compression Utility for Linux X86
Copyright 1989-2002 PKWARE Inc.  All Rights Reserved. Evaluation Version
PKZIP Reg. U.S. Pat. and Tm. Off.  Patent No. 5,051,745


Extracting files from .ZIP: teste.zip Inflating: arch1.txt Inflating: arch2.txt Inflating: arch3.txt Inflating: arch4.txt Inflating: arch5.txt

So, I need some help on how to write a regexp to get the values after inflating, that is the filenames, and put them in an array. Both outputs above are stored on a $stdout php variable.

Also, I need to be able to indentify errors with the unzip utility that does not support some types of zip file, the output is like this:

unzip test1.zip
Archive:  test1.zip
 skipping: test1.txt              `shrink' method not supported

There's a skipping instead of a inflating or Inflating in pkware.

The third situation is an error on the zip file itself :

unzip test2.zip
Archive:  test2.zip
End-of-central-directory signature not found.  Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive.  In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of test2.zip or
      test2.zip.zip, and cannot find test2.zip.ZIP, period.

or

pkunzip test2.zip
PKZIP(R)  Version 6.0  FAST!  Compression Utility for Linux X86
Copyright 1989-2002 PKWARE Inc.  All Rights Reserved. Evaluation Version
PKZIP Reg. U.S. Pat. and Tm. Off.  Patent No. 5,051,745

Extracting files from .ZIP: test2.zip
Errors were found in .ZIP file, attempt to fix (<Y>es/<N>o)? N

PKZIP: (Z152) No CE signature found

Help is much appreacited.

Thanks in advance to all.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to