Changeset 607

Show
Ignore:
Timestamp:
04/23/07 16:50:38 (1 year ago)
Author:
mikey
Message:

use latest version of starReader

Files:

Legend:

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

    r235 r607  
    154154        $this->parsePath($path); 
    155155        $current = self::acquire($this->archive); 
    156         return isset($current['index'][$this->id]); 
     156        if (isset($current['index'][$this->id]) == false) { 
     157            $this->parsePath(urldecode($path)); 
     158            $current = self::acquire($this->archive); 
     159            if (isset($current['index'][$this->id]) == false) { 
     160                return false; 
     161            } 
     162        } 
     163         
     164        return true; 
    157165    } 
    158166     
     
    214222 
    215223        if (isset($current['index'][$this->id]) == false) { 
    216             return false; 
     224            $this->parsePath(urldecode($path)); 
     225            $current = self::acquire($this->archive); 
     226            if (isset($current['index'][$this->id]) == false) { 
     227                return false; 
     228            } 
    217229        } 
    218230         
     
    250262?><?php StarStreamWrapper::register(); ?><?php 
    251263require 'star://' . __FILE__ . '?net.stubbles.star.StarClassRegistry'; 
    252 ?><?php __halt_compiler();star120070206161833net.stubbles.star.StarClassRegistryStarClassRegistry.phpsrc/main/php/net/stubbles/star48427448<?php 
     264?><?php __halt_compiler();star120070423164953net.stubbles.star.StarClassRegistryStarClassRegistry.phpsrc/main/php/net/stubbles/star55757890<?php 
    253265/** 
    254266 * Class registry for mapping of classes to star files. 
    255  *  
     267 * 
    256268 * @author   Frank Kleine <mikey@stubbles.net> 
     269 * @author   Stephan Schmidt <schst@stubbles.net> 
    257270 * @package  star 
    258271 */ 
    259272/** 
    260273 * Class registry for mapping of classes to star files. 
    261  *  
     274 * 
    262275 * @package  star 
    263276 */ 
     
    288301     */ 
    289302    protected static $files     = array(); 
    290      
     303 
    291304    /** 
    292305     * set the path to the star files 
     
    298311    { 
    299312        self::$libPathes[$libPath] = $recursive; 
    300     } 
    301      
     313        self::$initDone = false; 
     314    } 
     315 
    302316    /** 
    303317     * returns the file where the given classes is stored in 
     
    312326            return self::$classes[$fqClassName]; 
    313327        } 
    314          
     328 
    315329        return null; 
    316330    } 
    317      
     331 
    318332    /** 
    319333     * returns the uri for the given class 
     
    328342            return 'star://' . self::$classes[$fqClassName] . '?' . $fqClassName; 
    329343        } 
    330          
     344 
    331345        return null; 
    332346    } 
    333      
     347 
     348    /** 
     349     * returns all uris for a given resource 
     350     * 
     351     * @param   string  $fileName  file name of resource 
     352     * @return  array 
     353     */ 
     354    public static function getUrisForResource($resource) 
     355    { 
     356        self::init(); 
     357        $uris = array(); 
     358        foreach (self::$files as $file => $contents) { 
     359            foreach ($contents as $content) { 
     360                if ($content == $resource) { 
     361                    $uris[] = 'star://' . $file . '?' . $resource; 
     362                    continue 2; 
     363                } 
     364            } 
     365        } 
     366 
     367        return $uris; 
     368    } 
     369 
    334370    /** 
    335371     * returns a list of all classes within given file 
     
    344380            return self::$files[$file]; 
    345381        } 
    346          
     382 
    347383        return array(); 
    348384    } 
    349      
     385 
    350386    /** 
    351387     * initialize the class registry 
     
    356392            return; 
    357393        } 
    358          
     394 
    359395        if (count(self::$libPathes) == 0) { 
    360396            if (substr(__FILE__, 0, 7) == 'star://') { 
     
    365401            } 
    366402        } 
    367          
     403 
    368404        foreach (self::$libPathes as $libPath => $recursive) { 
    369405            if (file_exists($libPath . '/.cache') == true) { 
     
    374410                continue; 
    375411            } 
    376              
     412 
    377413            if (true === $recursive) { 
    378414                $dirIt = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($libPath)); 
     
    380416                $dirIt = new DirectoryIterator($libPath); 
    381417            } 
    382              
     418 
    383419            $cache['files']   = array(); 
    384420            $cache['classes'] = array(); 
     
    387423                    continue; 
    388424                } 
    389                  
     425 
    390426                $archiveData = StarStreamWrapper::acquire($file->getPathname()); 
    391427                if (empty($archiveData) == true) { 
    392428                    continue; 
    393429                } 
    394                  
     430 
    395431                $classes = array_keys($archiveData['index']); 
    396432                self::$files[$file->getPathname()]    = $classes; 
    397433                $cache['files'][$file->getPathname()] = $classes; 
    398                  
     434 
    399435                foreach ($archiveData['index'] as $fqClassName => $storeData) { 
    400436                    self::$classes[$fqClassName]    = $file->getPathname(); 
     
    402438                } 
    403439            } 
    404              
    405             file_put_contents($libPath . '/.cache', serialize($cache)); 
     440 
     441            $cacheFile = $libPath . '/.cache'; 
     442            if (!is_writable($libPath) && !is_writable($cacheFile)) { 
     443                throw new StarException("Unable to write starRegistry cache file to {$cacheFile}."); 
     444            } 
     445            file_put_contents($cacheFile, serialize($cache)); 
    406446            self::$initDone = true; 
    407447        } 
     
    409449} 
    410450?> 
     451title => Stubbles Archive Reader 
    411452package => net.stubbles.star 
    412453version => 0.5.0 
     454author => Stubbles Development Team <http://stubbles.net> 
     455copyright = © 2007 Stubbles Development Team