Changeset 225

Show
Ignore:
Timestamp:
02/06/07 11:50:51 (1 year ago)
Author:
mikey
Message:

added possibility to remove the base path of files packaged into a star so that only a directory structure is left that enables rebuilding from star files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/star/build.xml

    r218 r225  
    4242    <echo message="Source directory: ${build.src.dir}"/> 
    4343 
    44     <exec command="php &quot;${project.basedir}/build.php&quot; -i &quot;${project.basedir}/compile-writer-archive.ini&quot; -t &quot;${build.src.dir}/starWriter.php&quot;" /> 
    45     <exec command="php &quot;${project.basedir}/build.php&quot; -i &quot;${project.basedir}/compile-writer-cli.ini&quot; -t &quot;${build.src.dir}/starWriter-cli.php&quot;" /> 
    46     <exec command="php &quot;${project.basedir}/build.php&quot; -i &quot;${project.basedir}/compile-reader.ini&quot; -t &quot;${build.src.dir}/starReader.php&quot;" /> 
     44    <exec command="php &quot;${project.basedir}/build.php&quot; -i &quot;${project.basedir}/compile-writer-archive.ini&quot; -t &quot;${build.src.dir}/starWriter.php&quot; -r &quot;${pkg.dir}&quot;" /> 
     45    <exec command="php &quot;${project.basedir}/build.php&quot; -i &quot;${project.basedir}/compile-writer-cli.ini&quot; -t &quot;${build.src.dir}/starWriter-cli.php&quot; -r &quot;${pkg.dir}&quot;" /> 
     46    <exec command="php &quot;${project.basedir}/build.php&quot; -i &quot;${project.basedir}/compile-reader.ini&quot; -t &quot;${build.src.dir}/starReader.php&quot; -r &quot;${pkg.dir}&quot;" /> 
    4747  </target> 
    4848 
  • trunk/build/stubbles/build.php

    r219 r225  
    1616$srcDir = 'src' . DIRECTORY_SEPARATOR . 'main' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR; 
    1717$starArchive = new StarArchive(new StarWriter(dirname(__FILE__) . '/build/stubbles.php')); 
     18$removePath  = realpath(dirname(__FILE__) . '/../../'); 
    1819foreach ($dir as $file) { 
    1920    foreach ($forbidden as $test) { 
     
    2728    $id  = str_replace(DIRECTORY_SEPARATOR, '.', str_replace('.php', '', substr($file->getPathname(), $pos))); 
    2829    echo 'Adding ' . $id . "\n"; 
    29     $starArchive->add(new StarFile($file->getPathname()), $id); 
     30    $starArchive->add(new StarFile($file->getPathname(), $removePath), $id); 
    3031} 
    3132$dir    = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath(dirname(__FILE__) . '/../../src/main/resources'))); 
     
    4243    $id  = str_replace(DIRECTORY_SEPARATOR, '/', substr($file->getPathname(), $pos)); 
    4344    echo 'Adding ' . $id . "\n"; 
    44     $starArchive->add(new StarFile($file->getPathname()), $id); 
     45    $starArchive->add(new StarFile($file->getPathname(), $removePath), $id); 
    4546} 
    4647$starArchive->add(new StarFile(realpath(dirname(__FILE__) . '/../../src/main/php/net/stubbles/star/StarClassRegistry.php')), 'net.stubbles.star.StarClassRegistry'); 
  • trunk/src/main/php/net/stubbles/star/StarArchive.php

    r218 r225  
    6969        $data = $file->getContents(); 
    7070        $this->index[$id] = array('basename' => $file->getBaseName(), 
    71                                   'path'     => $file->getPath(), 
     71                                  'path'     => $file->getPathWithBaseRemoved(), 
    7272                                  'datasize' => strlen($data), 
    7373                                  'offset'   => -1, 
  • trunk/src/main/php/net/stubbles/star/StarConsole.php

    r137 r225  
    2424     * @var  array 
    2525     */ 
    26     private static $config = array('target'  => array('short'   => 't', 
    27                                                       'min'     => 0, 
    28                                                       'max'     => 1, 
    29                                                       'desc'    => 'Name of the archive to create.', 
    30                                                       'default' => '' 
    31                                                 ), 
    32                                    'ini'     => array('short'   => 'i', 
    33                                                       'min'     => 0, 
    34                                                       'max'     => 1, 
    35                                                       'desc'    => 'Name of the ini file to use.', 
    36                                                       'default' => '' 
    37                                                 ), 
    38                                    'verbose' => array('short'   => 'v', 
    39                                                       'min'     => 0, 
    40                                                       'max'     => 0, 
    41                                                       'desc'    => 'Be verbose.' 
    42                                                 ) 
     26    private static $config = array('target'     => array('short'   => 't', 
     27                                                         'min'     => 0, 
     28                                                         'max'     => 1, 
     29                                                         'desc'    => 'Name of the archive to create.', 
     30                                                         'default' => '' 
     31                                                   ), 
     32                                   'ini'        => array('short'   => 'i', 
     33                                                         'min'     => 0, 
     34                                                         'max'     => 1, 
     35                                                         'desc'    => 'Name of the ini file to use.', 
     36                                                         'default' => '' 
     37                                                   ), 
     38                                   'removePath' => array('short'   => 'r', 
     39                                                         'min'     => 0, 
     40                                                         'max'     => 1, 
     41                                                         'desc'    => 'Path to remove from logfiles.', 
     42                                                         'default' => '' 
     43                                                   ), 
     44                                   'verbose'    => array('short'   => 'v', 
     45                                                         'min'     => 0, 
     46                                                         'max'     => 0, 
     47                                                         'desc'    => 'Be verbose.' 
     48                                                   ) 
    4349                              ); 
    4450    /** 
     
    159165        $this->verbose('Writing star data to ' . $target . "\n"); 
    160166        $starArchive = new StarArchive(new StarWriter($target)); 
     167        $removePath  = null; 
     168        if ($this->args->isDefined('removePath') == true) { 
     169            $removePath = $this->args->getValue('removePath'); 
     170        } 
    161171        foreach ($conf['INCLUDES'] as $id => $fileName) { 
    162172            $this->verbose('Include ' . $fileName . ' with id ' . $id . "\n"); 
    163             $starArchive->add(new StarFile($fileName), $id); 
     173            $starArchive->add(new StarFile($fileName, $removePath), $id); 
    164174        } 
    165175         
  • trunk/src/main/php/net/stubbles/star/StarFile.php

    r124 r225  
    2020    protected $name; 
    2121     
     22    protected $removePath = null; 
     23     
    2224    /** 
    2325     * constructor 
    2426     * 
    25      * @param  string  $name  name of the file 
     27     * @param  string  $name        name of the file 
     28     * @param  string  $removePath  optional  part of the directory name that should be removed 
    2629     */ 
    27     public function __construct($name
     30    public function __construct($name, $removePath = null
    2831    { 
    29         $this->name = $name; 
     32        $this->name       = $name; 
     33        if (null !== $removePath) { 
     34            $this->removePath = realpath($removePath) . DIRECTORY_SEPARATOR; 
     35        } 
    3036    } 
    3137     
     
    8692        return dirname($this->name); 
    8793    } 
     94     
     95    public function getPathWithBaseRemoved() 
     96    { 
     97        if (null !== $this->removePath) { 
     98            return str_replace(DIRECTORY_SEPARATOR, '/', str_replace($this->removePath, '', $this->getPath())); 
     99        } 
     100         
     101        return $this->getPath(); 
     102    } 
    88103 
    89104    /**