Changeset 1211

Show
Ignore:
Timestamp:
01/11/08 09:52:16 (7 months ago)
Author:
mikey
Message:

use star 0.6.0 which uses Paamayim Nekudotayim as package separator
(still does not make star files work again, but is a first step)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/starReader.php

    r607 r1211  
    4444     */ 
    4545    protected $id; 
    46      
     46 
    4747    /** 
    4848     * registers the class as stream wrapper for the star protocol 
     
    6262        self::$registered = true; 
    6363    } 
    64      
     64 
    6565    /** 
    6666     * returns index of requested archive 
     
    7272    { 
    7373        static $archives = array(); 
     74        if (isset($archives[$archive]) == true) { 
     75            return $archives[$archive]; 
     76        } 
     77         
     78        $archives[$archive] = array(); 
    7479        if (file_exists($archive) == false) { 
    7580            return array(); 
    7681        } 
    77          
    78         if (isset($archives[$archive]) == false) { 
    79             $archives[$archive] = array(); 
    80             $current            =& $archives[$archive]; 
    81          
    82             $current['handle']  = fopen($archive, 'rb'); 
    83             if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { 
    84                 fseek($current['handle'], __COMPILER_HALT_OFFSET__); 
    85             } else { 
    86                 fseek($current['handle'], 0); 
    87             } 
    8882             
    89             $header = unpack('a4id/c1version/a8indexsize/a14buildtime/a*reserved', fread($current['handle'], 0x0100)); 
    90             if (false === $header) { 
    91                 // invalid star file 
    92                 return array(); 
    93             } 
     83        $current           =& $archives[$archive]; 
     84        $current['handle'] = fopen($archive, 'rb'); 
     85        if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { 
     86            fseek($current['handle'], __COMPILER_HALT_OFFSET__); 
     87        } else { 
     88            fseek($current['handle'], 0); 
     89        } 
     90         
     91        $header = unpack('a4id/c1version/a8indexsize/a14buildtime/a*reserved', fread($current['handle'], 0x0100)); 
     92        if (false === $header) { 
     93            // invalid star file 
     94            return array(); 
     95        } 
     96         
     97        $current['index']  = array(); 
     98        $current['header'] = $header; 
     99        if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { 
     100            $current['header']['totalSize'] = __COMPILER_HALT_OFFSET__ + 0x0100; 
     101        } else { 
     102            $current['header']['totalSize'] = 0x0100; 
     103        } 
     104         
     105        for ($i = 0; $i < $header['indexsize']; $i++) { 
     106            $entry = unpack('a80id/a72filename/a80path/a8size/a8offset/a*reserved', 
     107                            fread($current['handle'], 0x0100) 
     108                     ); 
    94109             
    95             $current['index']  = array(); 
    96             $current['header'] = $header; 
    97             if (__FILE__ == $archive && defined('__COMPILER_HALT_OFFSET__') == true) { 
    98                 $current['header']['totalSize'] = __COMPILER_HALT_OFFSET__ + 0x0100; 
    99             } else { 
    100                 $current['header']['totalSize'] = 0x0100; 
    101             } 
    102             for ($i = 0; $i < $header['indexsize']; $i++) { 
    103                 $entry = unpack('a80id/a72filename/a80path/a8size/a8offset/a*reserved', 
    104                                 fread($current['handle'], 0x0100) 
    105                 ); 
    106                  
    107                 $current['index'][$entry['id']]  = array('size' => (int) $entry['size'], 'offset' => (int) $entry['offset']); 
    108                 $current['header']['totalSize'] += 0x0100 + ((int) $entry['size']); 
    109             } 
     110            $current['index'][$entry['id']]  = array('size' => (int) $entry['size'], 'offset' => (int) $entry['offset']); 
     111            $current['header']['totalSize'] += 0x0100 + ((int) $entry['size']); 
    110112        } 
    111113         
    112114        return $archives[$archive]; 
    113115    } 
    114      
     116 
    115117    /** 
    116118     * returns the metadata of an archive 
     
    140142        return $metaData; 
    141143    } 
    142      
     144 
    143145    /** 
    144146     * open the stream 
     
    164166        return true; 
    165167    } 
    166      
     168 
    167169    /** 
    168170     * read the stream up to $count bytes 
     
    231233        return array('size' => $current['index'][$this->id]['size']); 
    232234    } 
    233      
     235 
    234236    /** 
    235237     * parses the path into class members 
     
    261263} 
    262264?><?php StarStreamWrapper::register(); ?><?php 
    263 require 'star://' . __FILE__ . '?net.stubbles.star.StarClassRegistry'; 
    264 ?><?php __halt_compiler();star120070423164953net.stubbles.star.StarClassRegistryStarClassRegistry.phpsrc/main/php/net/stubbles/star55757890<?php 
     265require 'star://' . __FILE__ . '?org::stubbles::star::StarClassRegistry'; 
     266?><?php __halt_compiler();star120080111092023org::stubbles::star::StarClassRegistryStarClassRegistry.phpsrc/main/php/org/stubbles/star62747808<?php 
    265267/** 
    266268 * Class registry for mapping of classes to star files. 
     
    311313    { 
    312314        self::$libPathes[$libPath] = $recursive; 
    313         self::$initDone = false; 
     315        self::$initDone            = false; 
    314316    } 
    315317 
     
    322324    public static function getFileForClass($fqClassName) 
    323325    { 
    324         self::init(); 
    325         if (isset(self::$classes[$fqClassName]) == true) { 
     326        if (false === self::$initDone) { 
     327            self::init(); 
     328        } 
     329         
     330        if (isset(self::$classes[$fqClassName]) === true) { 
    326331            return self::$classes[$fqClassName]; 
    327332        } 
     
    338343    public static function getUriForClass($fqClassName) 
    339344    { 
    340         self::init(); 
    341         if (isset(self::$classes[$fqClassName]) == true) { 
     345        if (false === self::$initDone) { 
     346            self::init(); 
     347        } 
     348         
     349        if (isset(self::$classes[$fqClassName]) === true) { 
    342350            return 'star://' . self::$classes[$fqClassName] . '?' . $fqClassName; 
    343351        } 
     
    354362    public static function getUrisForResource($resource) 
    355363    { 
    356         self::init(); 
     364        if (false === self::$initDone) { 
     365            self::init(); 
     366        } 
     367         
    357368        $uris = array(); 
    358369        foreach (self::$files as $file => $contents) { 
    359370            foreach ($contents as $content) { 
    360                 if ($content == $resource) { 
     371                if ($content === $resource) { 
    361372                    $uris[] = 'star://' . $file . '?' . $resource; 
    362373                    continue 2; 
     
    376387    public static function getClassNamesFromFile($file) 
    377388    { 
    378         self::init(); 
    379         if (isset(self::$files[$file]) == true) { 
     389        if (false === self::$initDone) { 
     390            self::init(); 
     391        } 
     392         
     393        if (isset(self::$files[$file]) === true) { 
    380394            return self::$files[$file]; 
    381395        } 
    382396 
    383397        return array(); 
     398    } 
     399 
     400    /** 
     401     * returns a list of all classes 
     402     * 
     403     * @return  string 
     404     */ 
     405    public static function getClasses() 
     406    { 
     407        return array_keys(self::$classes); 
    384408    } 
    385409 
     
    394418 
    395419        if (count(self::$libPathes) == 0) { 
    396             if (substr(__FILE__, 0, 7) == 'star://') { 
    397                 $path = str_replace('star://', '', str_replace('?net.stubbles.star.StarClassRegistry', '', __FILE__)); 
     420            if (substr(__FILE__, 0, 7) === 'star://') { 
     421                $path = str_replace('star://', '', str_replace('?org::stubbles::star::StarClassRegistry', '', __FILE__)); 
    398422                self::$libPathes[dirname($path)] = true; 
    399423            } else { 
     
    403427 
    404428        foreach (self::$libPathes as $libPath => $recursive) { 
    405             if (file_exists($libPath . '/.cache') == true) { 
     429            if (file_exists($libPath . '/.cache') === true) { 
    406430                $cache = unserialize(file_get_contents($libPath . '/.cache')); 
    407431                self::$files    = array_merge(self::$files, $cache['files']); 
     
    420444            $cache['classes'] = array(); 
    421445            foreach ($dirIt as $file) { 
    422                 if ($file->isFile() == false || substr($file->getPathname(), -14) == 'starReader.php' || (substr($file->getPathname(), -5) != '.star' && substr($file->getPathname(), -4) != '.php')) { 
     446                if ($file->isFile() === false || substr($file->getPathname(), -14) === 'starReader.php' || (substr($file->getPathname(), -5) !== '.star' && substr($file->getPathname(), -4) !== '.php')) { 
    423447                    continue; 
    424448                } 
     
    433457                $cache['files'][$file->getPathname()] = $classes; 
    434458 
    435                 foreach ($archiveData['index'] as $fqClassName => $storeData) { 
     459                foreach (array_keys($archiveData['index']) as $fqClassName) { 
    436460                    self::$classes[$fqClassName]    = $file->getPathname(); 
    437461                    $cache['classes'][$fqClassName] = $file->getPathname(); 
     
    440464 
    441465            $cacheFile = $libPath . '/.cache'; 
    442             if (!is_writable($libPath) && !is_writable($cacheFile)) { 
     466            if (is_writable($libPath) === false && is_writable($cacheFile) === false) { 
    443467                throw new StarException("Unable to write starRegistry cache file to {$cacheFile}."); 
    444468            } 
     469             
    445470            file_put_contents($cacheFile, serialize($cache)); 
    446471            self::$initDone = true; 
     
    449474} 
    450475?> 
     476 
    451477title => Stubbles Archive Reader 
    452 package => net.stubbles.star 
    453 version => 0.5.0 
     478package => org::stubbles::star 
     479version => 0.6.0 
    454480author => Stubbles Development Team <http://stubbles.net> 
    455 copyright = © 2007 Stubbles Development Team 
     481copyright = © 2007-2008 Stubbles Development Team