Returns all content classnames found  in $directory.

@param  string $directory The directory to look at.

@return string[]          An array of content classnames found in directory.
324182
public static function getClassContentClassnamesFromDir($directory)
    {
        if (!is_dir($directory)) {
            return [];
        }

        return array_map(
            function ($path) use ($directory) {
                return str_replace(
                    [DIRECTORY_SEPARATOR, '\\\\'],
                    [NAMESPACE_SEPARATOR, NAMESPACE_SEPARATOR],
                    AbstractClassContent::CLASSCONTENT_BASE_NAMESPACE.str_replace([$directory, '.yml'], ['', ''], $path)
                );
            },
            File::getFilesRecursivelyByExtension($directory, 'yml')
        );
    }
126476
protected function listDirectoryContents($directory = '.')
    {
        if ($directory && strpos($directory, '.') !== 0) {
            ftp_chdir($this->getConnection(), $directory);
        }

        $listing = @ftp_rawlist($this->getConnection(), '.') ?: [];

        $this->setConnectionRoot();

        return  $this->normalizeDirectoryListing($listing);
    }
582325
public function listFiles($directory = null, $ext = null)
    {
        if ($directory !== null) {
            // Add the directory separator
            $directory .= DIRECTORY_SEPARATOR;
        }

        if ($ext === null) {
            // Use the default extension
            $ext = 'php';
        }

        $paths = $this->getPaths();

        // Create an array for the files
        $found = [];

        foreach ($paths as $moduleName => $path) {
            if (is_dir($path = normalize_path($path.DIRECTORY_SEPARATOR.$directory))) {
                foreach ($this->filesystem->allFiles($path) as $file) {
                    $fileExt = $file->getExtension();

                    // Relative filename is the array key
                    $key = $file->getRelativePathname();

                    if (!empty($ext) and is_array($ext) ? !in_array($fileExt, $ext) : ($fileExt != $ext)) {
                        continue;
                    }

                    if (!isset($found[$key])) {
                        $found[$key] = $file;
                    }
                }
            }
        }

        // Sort the results alphabetically
        ksort($found);

        return $found;
    }
134866
public function cacheDirectory($directory)
    {
        $success = 0;
        $errors = 0;
        $errorDetails = [];

        $renderer = $this->getRenderer();
        $events = $renderer->getCompiler()->getEventListeners();

        foreach ($renderer->scanDirectory($directory) as $inputFile) {
            $renderer->initCompiler();
            $compiler = $renderer->getCompiler();
            $compiler->mergeEventListeners($events);
            $path = $inputFile;
            $this->isCacheUpToDate($path);
            $sandBox = $this->getRenderer()->getNewSandBox(function () use (&$success, $compiler, $path, $inputFile) {
                $this->cacheFileContents($path, $compiler->compileFile($inputFile), $compiler->getCurrentImportPaths());
                $success++;
            });
            $error = $sandBox->getThrowable();

            if ($error) {
                $errors++;
                $errorDetails[] = compact(['directory', 'inputFile', 'path', 'error']);
            }
        }

        return [$success, $errors, $errorDetails];
    }
549866
private function getFolderContent($dir)
    {
        $finder = Finder::create()
            ->ignoreVCS(false)
            ->ignoreDotFiles(false)
            ->depth(0)
            ->in($dir);

        return iterator_to_array($finder);
    }
373477
public function listDirectory($directory, $recursive = false)
    {
        $results = $this->scanDirectory($directory, $recursive);

        if (false === $results) {
            throw new \RuntimeException(sprintf(
                'Unable to list directory "%s", maybe it is not a directory '.
                'or it does not exist.',
                $directory
            ));
        }

        return array(
            'files'       => $results[0],
            'directories' => $results[1]
        );
    }
394237
public function directories($directory)
    {
        $directories = [];

        foreach (Finder::create()->in($directory)->directories()->depth(0)->sortByName() as $dir) {
            $directories[] = $dir->getPathname();
        }

        return $directories;
    }
1249478
public function getDirs($dir)
    {
        $dirArr = array();
        $files = ftp_rawlist($this->link, $dir);
        foreach ($files as $v) {
            $file = ltrim(strrchr($v, ' '), ' ');
            $path = "{$dir}/{$file}";
            if (preg_match('/^d/', $v)) {
                if (in_array($file, array('.', '..'))) {
                    continue;
                }
                if (preg_match('/^[a-zA-z0-9]+$/', $file)) { //file check
                    $dirArr[] = $path;
                    $dirArr = array_merge($dirArr, self::getDirs($path));
                }
            }
        }
        return $dirArr;
    }
1207882
public function files($directory)
    {
        $this->checkDirectory($directory);

        $disk = $this->disk();

        // TODO: Add a feature to exclude unwanted files.
        $files = array_map(function ($filePath) use ($disk, $directory) {
            return [
                'name'         => str_replace("$directory/", '', $filePath),
                'path'         => $filePath,
                'url'          => $disk->url($filePath),
                'mimetype'     => $disk->mimeType($filePath),
                'lastModified' => Carbon::createFromTimestamp($disk->lastModified($filePath))->toDateTimeString(),
                'visibility'   => $disk->getVisibility($filePath),
                'size'         => $disk->size($filePath),
            ];
        }, $disk->files($directory));

        return FileCollection::make($files)->exclude($this->getExcludedFiles());
    }
596912
public function items($directory)
    {
        $directory = ltrim($directory, "/");

        $iterator = new FilesystemIterator($this->pathRoot.$directory);

        $files = array();

        foreach ($iterator as $file) {
            $files[] = strval($file);
        }
        
        return $files;
    }
121139
public function listContents(string $directory = '', bool $recursive = false): array
    {
        list($prefix, $directory) = $this->getPrefixAndPath($directory);

        $fs     = $this->getFileSystem($prefix);
        $list   = $fs->listContents($directory, $recursive);

        foreach ($list as &$file) {
            $file['filesystem'] = $prefix;
        }

        unset($prefix, $directory, $fs);

        return $list;
    }
1213140
public function listDirectory($directory = '.', $ref = 'HEAD')
    {
        $directory  = FileSystem::normalizeDirectorySeparator($directory);
        $directory  = rtrim($directory, '/').'/';

        $args   = array(
            '--xml',
            '--revision' => $ref,
            $this->resolveLocalPath($directory)
        );

        /** @var $result CallResult */
        $result = $this->getSvn()->{'list'}($this->getRepositoryPath(), $args);
        $result->assertSuccess(sprintf('Cannot list directory "%s" at "%s" from "%s"',
            $directory, $ref, $this->getRepositoryPath()
        ));

        $xml    = simplexml_load_string($result->getStdOut());
        if (!$xml) {
            throw new \RuntimeException(sprintf('Cannot read list XML for "%s" at "%s" from "%s"',
                $directory, $ref, $this->getRepositoryPath()
            ));
        }

        $list = array();
        foreach ($xml->xpath('/lists/list/entry') as $item) {
            $list[]   = (string)$item->name;
        }
        return $list;
    }
10540
public function listContents(string $directory = '', bool $recursive = false): array
    {
        $list = [];
        $location = $this->applyBasePath($directory);

        if (! is_dir($location)) {
            return $list;
        }

        $iterator = $recursive ?
                    $this->getRecursiveDirectoryIterator($location) :
                    $this->getDirectoryIterator($location);

        foreach ($iterator as $file) {
            $path = $this->getFilePath($file);

            if (preg_match('#(^|/|\\\\)\.{1,2}$#', $path)) {
                continue;
            }

            $list[] = $this->normalizeFileInfo($file);

            unset($path);
        }

        unset($location, $iterator);

        return array_filter($list);
    }
955985
protected function listDirectoryContents($directory, $recursive = true)
    {
        $result = [];
        $connection = $this->getConnection();
        $location = $this->prefix($directory);
        $listing = $connection->rawlist($location);

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

        foreach ($listing as $filename => $object) {
            if (in_array($filename, ['.', '..'])) {
                continue;
            }

            $path = empty($directory) ? $filename : ($directory.'/'.$filename);
            $result[] = $this->normalizeListingObject($path, $object);

            if ($recursive && isset($object['type']) && $object['type'] === NET_SFTP_TYPE_DIRECTORY) {
                $result = array_merge($result, $this->listDirectoryContents($path));
            }
        }

        return $result;
    }
358669
protected static function get_file_list($directory) {
        global $CFG;
        $directoryroot = $CFG->dirroot;
        $finalfiles = array();
        if (is_dir($directory)) {
            if ($handle = opendir($directory)) {
                $files = scandir($directory);
                foreach ($files as $file) {
                    if ($file != '.' && $file != '..') {
                        // Ignore the file if it is external to the system.
                        if (strrpos($directory, $directoryroot) !== false) {
                            $location = substr($directory, strlen($directoryroot));
                            $name = substr($file, 0, -4);
                            $finalfiles[$name] = $location  . '/' . $file;
                        }
                    }
                }
            }
        }
        return $finalfiles;
    }
275408
protected function getFileNames(string $directory = 'default'): array
    {
        $directoryIterator = $this->getDirectoryIterator($directory);
        $files = [];
        foreach ($directoryIterator as $file) {
            $this->resolveFile($file, $files);
        }
        return $files;
    }
656132
private function readDirectoryContent(string $directory): void
    {
        $items = new DirectoryIterator($directory);

        foreach ($items as $item) {

            if ($item->isFile() && $this->isFile($item->getFilename())) {
                $this->readFileContent($item->getPathname());
            }
        }
    }