/** * Remove um diretório, junto com seus sub arquivos * e pastas. * * @param String $dir */ public function rmdir_rf($dir) { if (is_dir($dir)) { $objects = scandir($dir); if (count($objects) > 0) { foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir . "/" . $object) == "dir") { rmdir_rf($dir . "/" . $object); } else { unlink($dir . "/" . $object); } } } reset($objects); } rmdir($dir); } }
if (!file_exists($dirname . '__oo_extract_tmp/bar')) { echo "failed. bar file\n"; } else { echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; } if (!file_exists($dirname . '__oo_extract_tmp/foo')) { echo "failed. foo file\n"; } else { echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; } /* extract one file */ $zip->extractTo($dirname . '__oo_extract_tmp', 'bar'); if (!file_exists($dirname . '__oo_extract_tmp/bar')) { echo "failed. extract bar file\n"; } else { echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; } /* extract two files */ $zip->extractTo($dirname . '__oo_extract_tmp', array('bar', 'foo')); if (!file_exists($dirname . '__oo_extract_tmp/bar')) { echo "failed. extract bar file\n"; } else { echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; } if (!file_exists($dirname . '__oo_extract_tmp/foo')) { echo "failed. extract foo file\n"; } else { echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; } rmdir_rf($dirname . '__oo_extract_tmp');