1--TEST-- 2extractTo 3--EXTENSIONS-- 4zip 5--FILE-- 6<?php 7$dirname = __DIR__ . '/'; 8$file = $dirname . 'test_with_comment.zip'; 9include $dirname . 'utils.inc'; 10$zip = new ZipArchive; 11if ($zip->open($file) !== TRUE) { 12 echo "open failed.\n"; 13 exit('failed'); 14} 15 16$zip->extractTo($dirname . '__oo_extract_tmp'); 17if (!is_dir($dirname . '__oo_extract_tmp')) { 18 echo "failed. mkdir\n"; 19} 20 21if (!is_dir($dirname .'__oo_extract_tmp/foobar')) { 22 echo "failed. mkdir foobar\n"; 23} 24 25if (!file_exists($dirname . '__oo_extract_tmp/foobar/baz')) { 26 echo "failed. extract foobar/baz\n"; 27} else { 28 echo file_get_contents($dirname . '__oo_extract_tmp/foobar/baz') . "\n"; 29} 30 31if (!file_exists($dirname . '__oo_extract_tmp/bar')) { 32 echo "failed. bar file\n"; 33} else { 34 echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; 35} 36 37if (!file_exists($dirname . '__oo_extract_tmp/foo')) { 38 echo "failed. foo file\n"; 39} else { 40 echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; 41} 42 43 44/* extract one file */ 45$zip->extractTo($dirname . '__oo_extract_tmp', 'bar'); 46if (!file_exists($dirname . '__oo_extract_tmp/bar')) { 47 echo "failed. extract bar file\n"; 48} else { 49 echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; 50} 51 52/* extract two files */ 53$zip->extractTo($dirname . '__oo_extract_tmp', array('bar','foo')); 54if (!file_exists($dirname . '__oo_extract_tmp/bar')) { 55 echo "failed. extract bar file\n"; 56} else { 57 echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; 58} 59if (!file_exists($dirname . '__oo_extract_tmp/foo')) { 60 echo "failed. extract foo file\n"; 61} else { 62 echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; 63} 64 65rmdir_rf($dirname . '__oo_extract_tmp'); 66?> 67--EXPECT-- 68blabla laber rababer sülz 69 70bar 71 72foo 73 74 75bar 76 77bar 78 79foo 80