Beispiel #1
0
 function find($file)
 {
     foreach ($this->paths() as $loadPath) {
         $path = Path::join(array($loadPath, $file));
         if (file_exists($path)) {
             return $path;
         } else {
             foreach ($this->extensions() as $ext) {
                 if (file_exists($path . $ext)) {
                     return $path . $ext;
                 }
             }
         }
     }
     return false;
 }
Beispiel #2
0
 function write($options = array())
 {
     $dir = @$options["dir"];
     $compress = @$options["compress"] ?: false;
     $includeDigest = @$options["include_digest"] ?: false;
     $filename = Path::join(array($dir, $includeDigest ? $this->getDigestName() : $this->logicalPath));
     if (!is_dir(dirname($filename))) {
         mkdir(dirname($filename), 0777, true);
     }
     $body = $this->getBody();
     if ($compress) {
         $body = gzencode($body, 9);
         $filename .= ".gz";
     }
     @file_put_contents($filename, $body);
 }
Beispiel #3
0
 function resolve($path)
 {
     # Skip the load path if the path starts with `./`
     if (preg_match('{^\\.(/|\\\\)}', $path)) {
         $path = dirname($this->path) . DIRECTORY_SEPARATOR . $path;
     }
     # When resolving a directory either look for a file named
     # "$dir/index.$ext" or return the path to the directory (e.g.
     # for "require_tree").
     if (is_dir($path)) {
         $index = Path::join(array($path, "index{$this->getExtension()}"));
         if (file_exists($index)) {
             $path = $index;
         } else {
             $pathinfo = new PathInfo($path);
             if ($pathinfo->isAbsolute()) {
                 return $path;
             }
             return $this->environment->loadPaths->find($path);
         }
     }
     $pathinfo = new PathInfo($path);
     if ($pathinfo->isAbsolute()) {
         return $path;
     }
     return $this->environment->loadPaths->find($path);
 }