Exemple #1
0
 public static function getDirectoryFiles($dirName)
 {
     $files = array();
     $handle = opendir($dirName);
     if (!$handle) {
         return -1;
     }
     while (false !== ($file = readdir($handle))) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         $fileName = $dirName . '/' . $file;
         if (is_dir($fileName)) {
             $mp = self::getDirectoryFiles($fileName);
             $tmp = array_merge($files, $mp);
             $files = $tmp;
         } else {
             if (!($info = stat($fileName))) {
                 continue;
             }
             $fileSize = filesize($fileName);
             if ($fileSize <= 50) {
                 continue;
             }
             if (!($fileExt = strchr($file, '.'))) {
                 continue;
             }
             $fileExt = strtolower(substr($fileExt, 1));
             // Make sure it's a document type we can get text from
             if (($docType = FileUtility::getDocumentType($file)) == DOCUMENT_TYPE_UNKNOWN) {
                 continue;
             }
             $fileMp = array('realName' => $file, 'name' => $fileName, 'size' => $fileSize, 'ext' => $fileExt, 'type' => $docType, 'cTime' => $info['ctime'], 'parsed' => false);
             $files[] = $fileMp;
         }
     }
     return $files;
 }
 /**
  * Returns a document type based on its file extension and content type.
  * This is simply a wrapper for FileUtility::getDocumentType().
  *
  * @param string Document file name with extension.
  * @param string MIME content type.
  * @return flag Document type flag.
  */
 public function getDocumentType($fileName, $contentType = false)
 {
     return FileUtility::getDocumentType($fileName, $contentType);
 }