Get Files and folders

@param array $folder
@param bool  $excludeFolders

@return array
966899
public static function getFiles($folder, $excludeFolders = self::INCLUDE_FOLDERS)
    {
        $files = [];

        if (false === is_dir($folder)) {
            return [];
        }

        $handle = opendir($folder);
        while (false !== ($entry = readdir($handle))) {
            if (true === in_array($entry, self::getDirSymbols())) {
                continue;
            }

            if (self::EXCLUDE_FOLDERS === $excludeFolders && true === is_dir(sprintf('%s/%s', $folder, $entry))) {
                continue;
            }

            $files[] = $entry;
        }

        closedir($handle);

        return $files;
    }
746849
public function listDir(FileInterface $folder = null)
    {
        if ($folder) {
            $children = $this->nodeRepository->children($this->ensureEloquentFile($folder));
            return $this->ensureEloquentFiles($children);
        }

        /** @var Node $root */
        $root = $this->nodeRepoForDepth(1)->getByPathOrFail('/');

        return $this->ensureEloquentFiles($root->getChildren());
    }
135437
public static function include_files( $directory, $exclude_underscore = false ) {
		if ( ! is_dir( $directory ) ) {
			return;
		}

		$files = static::get_include_files( $directory, $exclude_underscore );

		foreach ( $files['files'] as $file ) {
			include_once( $file );
		}

		foreach ( $files['directories'] as $directory ) {
			static::include_files( $directory, $exclude_underscore );
		}
	}
1132560
public function getRecursiveFolders($folders)
    {
        if (! is_array($folders)) {
            $folders = [$folders];
        }

        $paths = [];

        foreach ($folders as $folder) {
            $iter = new Iterator(
                new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS),
                Iterator::SELF_FIRST,
                Iterator::CATCH_GET_CHILD // Ignore "Permission denied"
            );

            $subPaths = [$folder];
            foreach ($iter as $path => $dir) {
                if ($dir->isDir()) {
                    $subPaths[] = $path;
                }
            }

            $paths = array_merge($paths, $subPaths);
        }

        return $paths;
    }
773951
public function getFilesInFolder(\Google_Service_Drive_DriveFile $folder)
    {
        $query = 'trashed = false and \'' . $folder->getId() . '\' in parents';

        $fileList = $this->service->files->listFiles(array('q' => $query));

        return $fileList;

    }
1348636
public function parseFiles($files, $exclude = false)
    {
        $parser = $this->getParser();
        $result = [];
        foreach ($files as $path) {
            if ($exclude && preg_match($exclude, $path)) {
                continue;
            }
            try {
                $code = file_get_contents($path);
                $stmts = $parser->parse($code);
                $result[$path] = new CodeFile($stmts, $path);
            } catch (PhpParserError $e) {
                echo $path, ' Line ', $e->getLine(), ":\n";
                echo 'Parse Error: ', $e->getRawMessage();
                echo "\n";
            }
        }
        $this->_files = $result + $this->_files;
        return $result;
    }
843764
private function getExcludePaths(): array
    {
        $excludePaths = [];

        foreach ($this->excludePaths as $path) {
            $path = str_replace('*', '.*', $path);
            $excludePaths[] = '#' . str_replace($this->rootDirectory . '/', '', $path) . '#';
        }

        return $excludePaths;
    }
865626
public static function ListAllFiles( string $folder, bool $recursive = false ) : array
   {

      // Init the array that should contain the resulting file paths
      $files = [];

      if ( ! @\is_dir( $folder ) )
      {
         // No folder = we are done here
         return $files;
      }

      if ( ! $recursive )
      {
         // List only files directly contained inside $folder (none from sub folders)

         // Open the directory pointer
         $d = \dir( $folder );
         // Ignore . and ..
         $d->read(); $d->read();
         // loop the rest
         while ( false !== ( $entry = $d->read() ) )
         {
            $tmp = Path::Combine( $folder, $entry );
            if ( ! \is_file( $tmp ) )
            {
               // Ignore sub folders
               continue;
            }
            $files[] = $tmp;
         }
         $d->close();
         return $files;
      }

      // List all files, also from sub folders
      static::_listRecursive( $files, $folder );

      return $files;

   }
383945
private function get_files_from_folders( $path ) {

		$items = $this::get_folder_contents( $path );

		foreach ( $items as $type => &$location ) {
			$location = $this::get_folder_contents( trailingslashit( $location ) );
			sort( $location );
		}

		return $items;
	}
110341
protected function  getfiles($path, $allowFiles, &$files = array())
    {

        if (!is_dir($path)) return null;
        if(substr($path, strlen($path) - 1) != '/') $path .= '/';
        $handle = opendir($path);
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                $path2 = $path . $file;
                if (is_dir($path2)) {
                    $this->getfiles($path2, $allowFiles, $files);
                } else {
                    if (preg_match("/\.(".$allowFiles.")$/i", $file)) {
                        $files[] = array(
                            'url'=> str_replace(public_path(), '', $path2),
                            'mtime'=> filemtime($path2)
                        );
                    }
                }
            }
        }
        return $files;
    }
972691
private function gedcomFiles(string $folder): array
    {
        $d     = opendir($folder);
        $files = [];
        while (($f = readdir($d)) !== false) {
            if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) {
                $fp     = fopen(WT_DATA_DIR . $f, 'rb');
                $header = fread($fp, 64);
                fclose($fp);
                if (preg_match('/^(' . Gedcom::UTF8_BOM . ')?0 *HEAD/', $header)) {
                    $files[] = $f;
                }
            }
        }
        sort($files);

        return $files;
    }
788530
public function getFolder($folder = ''){
        $conn = substr($this->server,0,strpos($this->server, '}') + 1).$folder;
        return $conn;
    }
1187513
public static function delFolder($bucket, $folder) {
        if (empty($bucket) || empty($folder)) {
            return array(
                    'code' => COSAPI_PARAMS_ERROR,
                    'message' => 'bucket or path is empty');
        }

        $folder = self::normalizerPath($folder, True);

        return self::delBase($bucket, $folder);
    }
1115255
public function getFiles(array $dir_files, $files = array())
    {
        foreach ($dir_files as $file) {
            $filepath = $this->getFileManager()->DirTrim($this->getFileManager()->getDir(), $file, true);

            //Only show non-hidden files
            if ($file[0] != ".") {
                $files[] = new FileInfo($filepath, $this->getFileManager());
            }
        }
        return $files;
    }
1291667
protected function findFiles()
    {
        // Add php files.
        $finder = new Finder();
        $finder
            ->files()
            // Ignore version control system folder.
            ->ignoreVCS(true)
            // Do not add tests folders.
            ->exclude('Tests')
            ->exclude('tests')
            // Do not add composer backup folder.
            ->exclude('composer.bak');

        if (!empty($this->excludeFiles)) {
            foreach ($this->excludeFiles as $file) {
                $finder->notPath($file);
            }
        }

        return $finder;
    }
609784
public function createFolder($folder, $allFolders = FALSE)
    {
        if (substr($folder, -1) != '/') $folder = $folder . '/';
        if (!is_dir($folder)) {
            @mkdir($folder, 0777, $allFolders) or die ("Error creating folder '{$folder}'.");
        }
    }
1055787
public static function read(string $dir, string $includeRegEx = null, string $excludeRegEx = null):array
    {
        $files = [];
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException(
                sprintf('directory "%s" is not exist.', $dir)
            );
        }
        $iterators = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterators as $name => $file) {
            if (!$file->isDir() &&
                ($includeRegEx == null || preg_match($includeRegEx, basename($file))) &&
                ($excludeRegEx == null || !preg_match($excludeRegEx, basename($file)))
            ) {
                $files[] = $file->getRealPath();
            }
        }
        return $files;
    }