You are here

public function FMDiskFileSystem::getFiles in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

Overrides IFMDiskFileSystem::getFiles

File

vendor/edsdk/flmngr-server-php/src/fs/FMDiskFileSystem.php, line 175

Class

FMDiskFileSystem

Namespace

EdSDK\FlmngrServer\fs

Code

public function getFiles($dirPath) {

  // with "/root_dir_name" in the start
  $fullPath = $this
    ->getAbsolutePath($dirPath);
  if (!is_dir($fullPath)) {
    throw new MessageException(Message::createMessage(Message::DIR_DOES_NOT_EXIST, $dirPath));
  }
  $fFiles = scandir($fullPath);
  if ($fFiles === FALSE) {
    throw new MessageException(FMMessage::createMessage(FMMessage::FM_DIR_CANNOT_BE_READ));
  }
  $files = [];
  for ($i = 0; $i < count($fFiles); $i++) {
    $fFile = $fFiles[$i];
    $fileFullPath = $fullPath . '/' . $fFile;
    if (is_file($fileFullPath)) {
      try {
        $imageInfo = $this
          ->getImageInfo($fileFullPath);
      } catch (Exception $e) {
        error_log("Unable to process the image " . $fileFullPath);
        error_log($e);
        $imageInfo = new ImageInfo();
        $imageInfo->width = NULL;
        $imageInfo->height = NULL;
      }
      $file = new FMFile($dirPath, $fFile, filesize($fileFullPath), filemtime($fileFullPath), $imageInfo);
      $files[] = $file;
    }
  }
  return $files;
}