Beispiel #1
0
 /**
  *@param string $folder - Full path from directory
  *@return array
  */
 public static function RetrieveFilesFromFolder($folder, $pattern)
 {
     $array = array();
     if (!is_null($pattern)) {
         $pattern = str_replace(".", "\\.", $pattern);
         $pattern = str_replace("?", ".?", $pattern);
         $pattern = str_replace("*", ".*", $pattern);
     }
     if ($handle = FileUtil::OpenDirectory($folder)) {
         while ($file = FileUtil::ReadDirectory($handle)) {
             if (!is_dir($folder . self::Slash() . $file)) {
                 if (!is_null($pattern) && $pattern != "") {
                     if (preg_match("/{$pattern}/", $file)) {
                         $array[] = $folder . self::Slash() . $file;
                     }
                 } else {
                     $array[] = $folder . self::Slash() . $file;
                 }
             }
         }
         FileUtil::CloseDirectory($handle);
         return $array;
     }
 }