示例#1
0
 /**
  * Return list of the files in the path
  *
  * The array does not contain files, such as '.', '..', and files starting with '.'
  *
  * @param string $path Path of target directory
  * @param string $filter If specified, return only files matching with the filter
  * @param bool $to_lower If TRUE, file names will be changed into lower case.
  * @param bool $concat_prefix If TRUE, return file name as absolute path
  * @return string[] Array of the filenames in the path
  */
 public static function readDir($path, $filter = '', $to_lower = FALSE, $concat_prefix = FALSE)
 {
     $list = Rhymix\Framework\Storage::readDirectory(self::getRealPath($path), $concat_prefix, true, false);
     if (!$list) {
         return array();
     }
     $output = array();
     foreach ($list as $filename) {
         $filename = str_replace(array('\\', '//'), '/', $filename);
         $basename = $concat_prefix ? basename($filename) : $filename;
         if ($basename[0] === '.' || $filter && !preg_match($filter, $basename)) {
             continue;
         }
         if ($to_lower) {
             $filename = strtolower($filename);
         }
         if ($filter) {
             $filename = preg_replace($filter, '$1', $filename);
         }
         $output[] = $filename;
     }
     return $output;
 }