예제 #1
0
 /**
  * Attempts to find a file given a relative path
  *
  * @param \r8\Finder\Tracker $tracker $file The tracker to use when determining
  *      if a base/path combination is valid
  * @param String $base The base directory to look for the path in
  * @param String $path The path being looked for
  * @return \r8\Finder\Result|NULL Returns a result, or NULL if the file couldn't be found
  */
 public function find(\r8\Finder\Tracker $tracker, $base, $path)
 {
     $includePaths = explode(\PATH_SEPARATOR, ini_get("include_path"));
     foreach ($includePaths as $inc) {
         $result = $this->wrapped->find($tracker, $inc, $path);
         if ($result instanceof \r8\Finder\Result) {
             return $result;
         }
     }
     return NULL;
 }
예제 #2
0
 /**
  * Attempts to find the absolute path of a file given a relative path
  *
  * @param String $path The relative path of the file being looked for
  * @param Boolean $volatile If true, an exception will be thrown when a
  *      file is not found
  * @return \r8\Finder\Result|NULL Returns the found file. Returns NULL if the
  *      file could not be found
  */
 public function find($path, $volatile = FALSE)
 {
     $tracker = new \r8\Finder\Tracker();
     $result = $this->finder->find($tracker, $this->base, $path);
     if (!$result instanceof \r8\Finder\Result) {
         if ($volatile) {
             throw new \r8\Exception\Finder\Missing($path, $tracker);
         }
         return NULL;
     }
     return $result;
 }
예제 #3
0
 /**
  * Attempts to find a file given a relative path
  *
  * @param \r8\Finder\Tracker $tracker $file The tracker to use when determining
  *      if a base/path combination is valid
  * @param String $base The base directory to look for the path in
  * @param String $path The path being looked for
  * @return \r8\Finder\Result|NULL Returns a result, or NULL if the file
  *      couldn't be found
  */
 public function find(\r8\Finder\Tracker $tracker, $base, $path)
 {
     foreach ($this->dirs as $inc) {
         $result = $this->wrapped->find($tracker, $inc, $path);
         if ($result instanceof \r8\Finder\Result) {
             return $result;
         }
     }
     return NULL;
 }
예제 #4
0
 /**
  * Attempts to find a file given a relative path
  *
  * @param \r8\Finder\Tracker $tracker $file The tracker to use when determining
  *      if a base/path combination is valid
  * @param String $base The base directory to look for the path in
  * @param String $path The path being looked for
  * @return \r8\Finder\Result|NULL Returns a result, or NULL if the file couldn't be found
  */
 public function find(\r8\Finder\Tracker $tracker, $base, $path)
 {
     if (count($this->subdirs) == 0) {
         return $this->wrapped->find($tracker, $base, $path);
     }
     $path = trim((string) $path, "/");
     foreach ($this->subdirs as $subdir) {
         $result = $this->wrapped->find($tracker, $base, $subdir . "/" . $path);
         if ($result instanceof \r8\Finder\Result) {
             return $result;
         }
     }
     return NULL;
 }
예제 #5
0
 /**
  * Attempts to find a file given a relative path
  *
  * @param \r8\Finder\Tracker $tracker $file The tracker to use when determining
  *      if a base/path combination is valid
  * @param String $base The base directory to look for the path in
  * @param String $path The path being looked for
  * @return \r8\Finder\Result|NULL Returns a result, or NULL if the file
  *      couldn't be found
  */
 public function find(\r8\Finder\Tracker $tracker, $base, $path)
 {
     if (count($this->exts) == 0) {
         return $this->wrapped->find($tracker, $base, $path);
     }
     $path = rtrim((string) $path, ".");
     foreach ($this->exts as $ext) {
         $result = $this->wrapped->find($tracker, $base, $path . "." . $ext);
         if ($result instanceof \r8\Finder\Result) {
             return $result;
         }
     }
     return NULL;
 }
예제 #6
0
 /**
  * Attempts to find a file given a relative path
  *
  * @param \r8\Finder\Tracker $tracker $file The tracker to use when determining
  *      if a base/path combination is valid
  * @param String $base The base directory to look for the path in
  * @param String $path The path being looked for
  * @return \r8\Finder\Result|NULL Returns a result, or NULL if the file couldn't be found
  */
 public function find(\r8\Finder\Tracker $tracker, $base, $path)
 {
     $origPath = $path;
     $path = trim((string) $path, "/");
     $path = \r8\FileSys::resolvePath($path);
     // Iterate over each possible mutation and determine if it should be applied
     foreach ($this->mutations as $mutate) {
         $result = NULL;
         // Check for a partial match
         if (\r8\str\startsWith($path, $mutate["from"] . "/")) {
             $result = $this->wrapped->find($tracker, $base, $mutate["to"] . "/" . ltrim(substr($path, strlen($mutate["from"])), "/"));
         } else {
             if (strcasecmp($path, $mutate["from"]) == 0) {
                 $result = $this->wrapped->find($tracker, $base, $mutate["to"]);
             }
         }
         if ($result instanceof \r8\Finder\Result) {
             return $result;
         }
     }
     return $this->wrapped->find($tracker, $base, $origPath);
 }