|
SPL-StandardPHPLibrary
|
00001 <?php 00002 00016 if ($argc < 3) 00017 { 00018 echo <<<EOF 00019 php phar_from_dir.php archive directory [regex] 00020 00021 Packs files in a given directory into a phar archive. 00022 00023 archive name of the archive to create 00024 directory input directory to pack 00025 regex optional expression to match files in directory 00026 00027 EOF; 00028 exit(1); 00029 } 00030 00031 $phar = new Phar($argv[1], 0, 'newphar'); 00032 00033 $dir = new RecursiveDirectoryIterator($argv[2]); 00034 $dir = new RecursiveIteratorIterator($dir); 00035 if ($argc > 3) 00036 { 00037 $dir = new RegexIterator($dir, '/'.$argv[3].'/'); 00038 } 00039 00040 $phar->begin(); 00041 00042 foreach($dir as $file) 00043 { 00044 echo "$file\n"; 00045 copy($file, "phar://newphar/$file"); 00046 } 00047 00048 $phar->commit(); 00049 00050 ?>
1.7.5.1