Beispiel #1
0
 /**
  * @param mixed $pattern A filter pattern as a string (same as *NIX shell), or an
  * array of possible patterns.
  * @param int $flags GLOB_NORMAL | GLOB_ONLY_DIR | GLOB_DIR_IGNORE_PATTERN
  *                       | GLOB_DIR_FIRST | GLOB_FORCE_SCANDIR | GLOB_CASEINSENSITIVE
  * 					(@see class AdvancedPathLib)
  * @return array(IFile) The list of the files contained in the "file" itself if $this
  * is a directory, or the files contained in the parent directory if $this is a
  * normal file
  * @throws EyeIOException
  */
 public function listFiles($pattern = '*', $flags = AdvancedPathLib::GLOB_NORMAL)
 {
     if (!$this->isDirectory()) {
         throw new EyeBadMethodCallException('Cannot list files: ' . $this->path . ' is not a directory.');
     }
     $dirPath = $this->getAbsolutePath();
     try {
         $files = AdvancedPathLib::glob($dirPath, $pattern, $flags);
     } catch (Exception $e) {
         throw new EyeIOException('Unable to list files in directory ' . $dirPath . '.', 0, $e);
     }
     $filesObjects = array();
     $thisClass = get_class($this);
     foreach ($files as $filepath) {
         try {
             $filesObjects[] = new $thisClass($filepath);
         } catch (Exception $e) {
             throw new EyeIOException('Unable to create file object for ' . $filepath . '.', 0, $e);
         }
     }
     return $filesObjects;
 }