From 8adf44cc65b3b89167ed641bb3aabfb82afaccf4 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sat, 12 Aug 2006 15:54:51 +0000 Subject: [PATCH] - add check for the return values ZipArchive::open, some examples were not updated. Braindead--; git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@218030 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../zip/functions/ziparchive-addfile.xml | 4 ++-- .../functions/ziparchive-addfromstring.xml | 6 +++--- .../zip/functions/ziparchive-deleteindex.xml | 4 ++-- .../zip/functions/ziparchive-deletename.xml | 4 ++-- .../zip/functions/ziparchive-extractto.xml | 4 ++-- .../ziparchive-getarchivecomment.xml | 4 ++-- .../zip/functions/ziparchive-getfromindex.xml | 4 ++-- .../zip/functions/ziparchive-getfromname.xml | 13 ++++++------ .../zip/functions/ziparchive-getstream.xml | 21 ++++++++++--------- 9 files changed, 33 insertions(+), 31 deletions(-) diff --git a/reference/zip/functions/ziparchive-addfile.xml b/reference/zip/functions/ziparchive-addfile.xml index 3efe0a88e6..47ffdd93ea 100644 --- a/reference/zip/functions/ziparchive-addfile.xml +++ b/reference/zip/functions/ziparchive-addfile.xml @@ -1,5 +1,5 @@ - + ZipArchive::addFile @@ -59,7 +59,7 @@ open('test.zip')) { +if ($zip->open('test.zip') === TRUE) { $zip->addFile('/path/to/index.txt'), 'newname.txt'); $zip->close(); echo 'ok'; diff --git a/reference/zip/functions/ziparchive-addfromstring.xml b/reference/zip/functions/ziparchive-addfromstring.xml index 325460834d..fba42d1876 100644 --- a/reference/zip/functions/ziparchive-addfromstring.xml +++ b/reference/zip/functions/ziparchive-addfromstring.xml @@ -1,5 +1,5 @@ - + ZipArchive::addFromString @@ -55,7 +55,7 @@ open('test.zip', ZipArchive::CREATE); -if ($res) { +if ($res === TRUE) { $zip->addFromString('test.txt', 'file content goes here'); $zip->close(); echo 'ok'; @@ -72,7 +72,7 @@ if ($res) { open(realpath('test.zip'))) { +if ($zip->open('test.zip') === TRUE) { $zip->addFromString('dir/test.txt', 'file content goes here'); $zip->close(); echo 'ok'; diff --git a/reference/zip/functions/ziparchive-deleteindex.xml b/reference/zip/functions/ziparchive-deleteindex.xml index 3d7976337f..4ec4aff78f 100644 --- a/reference/zip/functions/ziparchive-deleteindex.xml +++ b/reference/zip/functions/ziparchive-deleteindex.xml @@ -1,5 +1,5 @@ - + ZipArchive::deleteIndex @@ -44,7 +44,7 @@ open(realpath('test.zip'))) { +if ($zip->open('test.zip') === TRUE) { $zip->deleteIndex(2); $zip->close(); echo 'ok'; diff --git a/reference/zip/functions/ziparchive-deletename.xml b/reference/zip/functions/ziparchive-deletename.xml index 990486044b..26f6ff440e 100644 --- a/reference/zip/functions/ziparchive-deletename.xml +++ b/reference/zip/functions/ziparchive-deletename.xml @@ -1,5 +1,5 @@ - + ZipArchive::deleteName @@ -44,7 +44,7 @@ open(realpath('test1.zip'))) { +if ($zip->open('test1.zip') === TRUE) { $zip->deleteName('testfromfile.php'); $zip->close(); echo 'ok'; diff --git a/reference/zip/functions/ziparchive-extractto.xml b/reference/zip/functions/ziparchive-extractto.xml index 19bcfb471f..c0a3653003 100644 --- a/reference/zip/functions/ziparchive-extractto.xml +++ b/reference/zip/functions/ziparchive-extractto.xml @@ -1,5 +1,5 @@ - + ZipArchive::extractTo @@ -61,7 +61,7 @@ open('test.zip')) { +if ($zip->open('test.zip') === TRUE) { $zip->extractTo('/my/destination/dir/'); $zip->close(); echo 'ok'; diff --git a/reference/zip/functions/ziparchive-getarchivecomment.xml b/reference/zip/functions/ziparchive-getarchivecomment.xml index 016ace2460..8196b13f7f 100644 --- a/reference/zip/functions/ziparchive-getarchivecomment.xml +++ b/reference/zip/functions/ziparchive-getarchivecomment.xml @@ -1,5 +1,5 @@ - + ZipArchive::getArchiveComment @@ -63,4 +63,4 @@ End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 ---> \ No newline at end of file +--> diff --git a/reference/zip/functions/ziparchive-getfromindex.xml b/reference/zip/functions/ziparchive-getfromindex.xml index 66b164f138..4dfb63e0a0 100644 --- a/reference/zip/functions/ziparchive-getfromindex.xml +++ b/reference/zip/functions/ziparchive-getfromindex.xml @@ -1,5 +1,5 @@ - + ZipArchive::getFromIndex @@ -66,7 +66,7 @@ open(realpath('test.zip'))) { +if ($zip->open('test.zip') === TRUE) { echo $zip->getFromIndex(2); $zip->close(); } else { diff --git a/reference/zip/functions/ziparchive-getfromname.xml b/reference/zip/functions/ziparchive-getfromname.xml index c8c8e6f867..1f32a41e19 100644 --- a/reference/zip/functions/ziparchive-getfromname.xml +++ b/reference/zip/functions/ziparchive-getfromname.xml @@ -1,5 +1,5 @@ - + ZipArchive::getFromName @@ -76,7 +76,7 @@ open(realpath('test1.zip'))) { +if ($zip->open('test1.zip') === TRUE) { echo $zip->getFromName('testfromfile.php'); $zip->close(); } else { @@ -92,10 +92,11 @@ if ($zip->open(realpath('test1.zip'))) { open(dirname(__FILE__) . '/test_im.zip'); -$im_string = $z->getFromName("pear_item.gif"); -$im = imagecreatefromstring($im_string); -imagepng($im, 'b.png'); +if ($z->open(dirname(__FILE__) . '/test_im.zip')) { + $im_string = $z->getFromName("pear_item.gif"); + $im = imagecreatefromstring($im_string); + imagepng($im, 'b.png'); +} ?> ]]> diff --git a/reference/zip/functions/ziparchive-getstream.xml b/reference/zip/functions/ziparchive-getstream.xml index 3fe298dd80..dd50d8f8ba 100644 --- a/reference/zip/functions/ziparchive-getstream.xml +++ b/reference/zip/functions/ziparchive-getstream.xml @@ -1,5 +1,5 @@ - + ZipArchive::getStream @@ -46,17 +46,18 @@ open(dirname(__FILE__) . '/test.zip'); -$fp = $z->getStream('test'); -if(!$fp) exit("failed\n"); +if ($z->open('test.zip')) { + $fp = $z->getStream('test'); + if(!$fp) exit("failed\n"); -while (!feof($fp)) { - $contents .= fread($fp, 2); + while (!feof($fp)) { + $contents .= fread($fp, 2); + } + + fclose($fp); + file_put_contents('t',$contents); + echo "done.\n"; } - -fclose($fp); -file_put_contents('t',$contents); -echo "done.\n"; ?> ]]>