root/branches/1.0.x/build/mkmanifest.php

Revision 386, 2.3 kB (checked in by laurentj, 2 years ago)

source code of jelix is now in UTF-8; fix misprint into jelix~format.* locales; improved jUrl::escape utf-8 compliance

Line 
1 <?php
2
3 /**
4 * @package     jBuildTools
5 * @author      Jouanneau Laurent
6 * @contributor
7 * @copyright   2006-2007 Jouanneau laurent
8 * @link        http://www.jelix.org
9 * @licence     GNU General Public Licence see LICENCE file or http://www.gnu.org/licenses/gpl.html
10 */
11
12 require_once(dirname(__FILE__).'/lib/jCmdUtils.class.php');
13
14 // arguments :  repertoire1 [repertoire2]
15 // repertoire1 : le chemin du repertoire duquel on veut la liste
16 // repertoire2 : si on veut une base de chemin différente de repertoire1 dans le fichier de sortie
17 //               on l'indique ici
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 ?>
Note: See TracBrowser for help on using the browser.
Download in other formats: Plain Text Original Format