You are here

private function FMDiskFileSystem::getDirs__fill in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

1 call to FMDiskFileSystem::getDirs__fill()
FMDiskFileSystem::getDirs in vendor/edsdk/flmngr-server-php/src/fs/FMDiskFileSystem.php

File

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

Class

FMDiskFileSystem

Namespace

EdSDK\FlmngrServer\fs

Code

private function getDirs__fill(&$dirs, $fDir, $path) {
  $files = scandir($fDir);
  if ($files === FALSE) {
    throw new MessageException(FMMessage::createMessage(FMMessage::FM_UNABLE_TO_LIST_CHILDREN_IN_DIRECTORY));
  }
  $dirsCount = 0;
  $filesCount = 0;
  for ($i = 0; $i < count($files); $i++) {
    $file = $files[$i];
    if ($file === '.' || $file === '..') {
      continue;
    }
    if (is_file($fDir . '/' . $file)) {
      $filesCount++;
    }
    else {
      if (is_dir($fDir . '/' . $file)) {
        $dirsCount++;
      }
    }
  }
  $i = strrpos($fDir, '/');
  if ($i !== FALSE) {
    $dirName = substr($fDir, $i + 1);
  }
  else {
    $dirName = $fDir;
  }
  $dir = new FMDir($dirName, $path, $filesCount, $dirsCount);
  $dirs[] = $dir;
  for ($i = 0; $i < count($files); $i++) {
    if ($files[$i] !== '.' && $files[$i] !== '..') {
      if (is_dir($fDir . '/' . $files[$i])) {
        $this
          ->getDirs__fill($dirs, $fDir . '/' . $files[$i], $path . (strlen($path) > 0 ? "/" : "") . $dirName);
      }
    }
  }
}