1--TEST-- 2ZipArchive::addGlob() method 3--CREDITS-- 4Sammy Kaye Powers <sammyk@sammykmedia.com> 5w/Kenzo over the shoulder 6#phptek Chicago 2014 7--SKIPIF-- 8<?php 9if(!extension_loaded('zip')) die('skip'); 10if(!defined("GLOB_BRACE")) die ('skip'); 11?> 12--FILE-- 13<?php 14$dirname = dirname(__FILE__) . '/'; 15include $dirname . 'utils.inc'; 16$file = $dirname . '__tmp_oo_addglob.zip'; 17 18copy($dirname . 'test.zip', $file); 19touch($dirname . 'foo.txt'); 20touch($dirname . 'bar.baz'); 21 22$zip = new ZipArchive(); 23if (!$zip->open($file)) { 24 exit('failed'); 25} 26$options = array('add_path' => 'baz/', 'remove_all_path' => TRUE); 27if (!$zip->addGlob($dirname . '*.{txt,baz}', GLOB_BRACE, $options)) { 28 echo "failed1\n"; 29} 30if ($zip->status == ZIPARCHIVE::ER_OK) { 31 dump_entries_name($zip); 32 $zip->close(); 33} else { 34 echo "failed2\n"; 35} 36?> 37--CLEAN-- 38<?php 39$dirname = dirname(__FILE__) . '/'; 40unlink($dirname . '__tmp_oo_addglob.zip'); 41unlink($dirname . 'foo.txt'); 42unlink($dirname . 'bar.baz'); 43?> 44--EXPECT-- 450 bar 461 foobar/ 472 foobar/baz 483 entry1.txt 494 baz/foo.txt 505 baz/bar.baz 51