Changeset 361
- Timestamp:
- 01/27/07 22:59:28 (2 years ago)
- Files:
-
- trunk/build/mkmanifest.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/mkmanifest.php
r279 r361 3 3 /** 4 4 * @package jBuildTools 5 * @version $Id$6 5 * @author Jouanneau Laurent 7 6 * @contributor 8 * @copyright 2006 Jouanneau laurent7 * @copyright 2006-2007 Jouanneau laurent 9 8 * @link http://www.jelix.org 10 9 * @licence GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html 11 10 */ 11 12 require_once(dirname(__FILE__).'/lib/jCmdUtils.class.php'); 12 13 13 14 // arguments : repertoire1 [repertoire2] … … 16 17 // on l'indique ici 17 18 18 if($_SERVER['argc'] < 2){ 19 echo "too few arguments\n repertoire1 [repertoire2]\n"; 20 exit(1); 21 } 22 array_shift($_SERVER['argv']); // shift the script name 23 $nbarg=$_SERVER['argc'] -1; 19 try{ 20 $sws = array('-e'=>false); 21 $params = array('dirpath'=>true, 'basepath'=>false); 22 23 list($switches, $parameters) = jCmdUtils::getOptionsAndParams($_SERVER['argv'], $sws, $params); 24 24 25 $options = array('verbose'=>false); 26 27 if(substr($_SERVER['argv'][0],0,1) == '-'){ 28 $nbarg--; 29 $sw = substr(array_shift($_SERVER['argv']),1); 30 $options['verbose'] = (strpos('v', $sw) !== false); 25 }catch(Exception $e){ 26 echo "\nmkmanifest error : " , $e->getMessage(),"\n"; 27 echo " options : [-e] dirpath [basepath] 28 -e : include empty directory\n"; 29 exit(1); 31 30 } 32 31 33 if($nbarg == 1){ 34 list($dirpath) = $_SERVER['argv']; 35 $basepath=''; 36 }elseif($nbarg == 2){ 37 list($dirpath, $basepath) = $_SERVER['argv']; 38 }else{ 39 echo "too few arguments\n"; 40 exit(1); 41 } 42 43 $hasError =false; 32 $dirpath = $parameters['dirpath']; 33 $basepath = $parameters['basepath']; 44 34 45 35 if(substr($dirpath,-1) == '/'){ 46 36 $dirpath=substr($dirpath,0,-1); 47 37 } 48 49 38 if($basepath == ''){ 50 39 $basepath = $dirpath; … … 55 44 } 56 45 46 47 57 48 function mkpath($dir, $basepath){ 49 global $switches; 58 50 $output=''; 59 51 if ($dh = opendir($dir)) { … … 65 57 $type= filetype($dir.'/'.$file); 66 58 if($type == 'dir'){ 67 if($file != '.' && $file !='..' ) 59 if($file != '.' && $file !='..' ){ 68 60 $dirlist[]=$file; 61 } 69 62 }else{ 70 63 if(!$cdok){ … … 77 70 closedir($dh); 78 71 72 if(!$cdok && count($dirlist) == 0 && isset($switches['-e'])){ 73 $output.="cd ".$basepath."\n"; 74 } 75 79 76 foreach($dirlist as $d){ 80 77 $output.=mkpath( $dir.'/'.$d, $basepath.'/'.$d); 81 78 } 82 79 }else{ 83 //echo "erreur ouverture repertoire $dir\n"; 80 echo "erreur ouverture repertoire $dir\n"; 81 exit(1); 84 82 } 85 83 return $output; … … 92 90 $output=mkpath($dirpath,$basepath); 93 91 }else{ 94 //echo "mauvais repertoire $dir\n"; 92 echo "mauvais repertoire $dirpath\n"; 93 exit(1); 95 94 } 96 95 97 96 echo $output; 98 99 if($hasError) 100 exit(1); 101 else 102 exit(0); 97 exit(0); 103 98 ?>
