| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
require_once(dirname(__FILE__).'/lib/jCmdUtils.class.php'); |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 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 |
|
|---|
| 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); |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
$dirpath = $parameters['dirpath']; |
|---|
| 33 |
$basepath = $parameters['basepath']; |
|---|
| 34 |
|
|---|
| 35 |
if(substr($dirpath,-1) == '/'){ |
|---|
| 36 |
$dirpath=substr($dirpath,0,-1); |
|---|
| 37 |
} |
|---|
| 38 |
if($basepath == ''){ |
|---|
| 39 |
$basepath = $dirpath; |
|---|
| 40 |
}else{ |
|---|
| 41 |
if(substr($basepath,-1) == '/'){ |
|---|
| 42 |
$basepath=substr($basepath,0,-1); |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
function mkpath($dir, $basepath){ |
|---|
| 49 |
global $switches; |
|---|
| 50 |
$output=''; |
|---|
| 51 |
if ($dh = opendir($dir)) { |
|---|
| 52 |
$dirlist=array(); |
|---|
| 53 |
$cdok=false; |
|---|
| 54 |
while (($file = readdir($dh)) !== false) { |
|---|
| 55 |
if($file == '.svn') |
|---|
| 56 |
continue; |
|---|
| 57 |
$type= filetype($dir.'/'.$file); |
|---|
| 58 |
if($type == 'dir'){ |
|---|
| 59 |
if($file != '.' && $file !='..' ){ |
|---|
| 60 |
$dirlist[]=$file; |
|---|
| 61 |
} |
|---|
| 62 |
}else{ |
|---|
| 63 |
if(!$cdok){ |
|---|
| 64 |
$output.="cd ".$basepath."\n"; |
|---|
| 65 |
$cdok=true; |
|---|
| 66 |
} |
|---|
| 67 |
$output.=" ".$file."\n"; |
|---|
| 68 |
} |
|---|
| 69 |
} |
|---|
| 70 |
closedir($dh); |
|---|
| 71 |
|
|---|
| 72 |
if(!$cdok && count($dirlist) == 0 && isset($switches['-e'])){ |
|---|
| 73 |
$output.="cd ".$basepath."\n"; |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
foreach($dirlist as $d){ |
|---|
| 77 |
$output.=mkpath( $dir.'/'.$d, $basepath.'/'.$d); |
|---|
| 78 |
} |
|---|
| 79 |
}else{ |
|---|
| 80 |
echo "erreur ouverture repertoire $dir\n"; |
|---|
| 81 |
exit(1); |
|---|
| 82 |
} |
|---|
| 83 |
return $output; |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
$output=''; |
|---|
| 89 |
if (is_dir($dirpath)) { |
|---|
| 90 |
$output=mkpath($dirpath,$basepath); |
|---|
| 91 |
}else{ |
|---|
| 92 |
echo "mauvais repertoire $dirpath\n"; |
|---|
| 93 |
exit(1); |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
echo $output; |
|---|
| 97 |
exit(0); |
|---|
| 98 |
?> |
|---|