@param $dir

@return array
764617
public function refreshOverseaDir($dir)
    {
        $dirs = is_array($dir) ? $dir : func_get_args();

        return $this->request($dirs, 'dirs', 'RefreshCdnOverSeaDir');
    }
188242
protected function getMigrationFilesFromDirectory(String $directory) : Array
	{
		$files = [];
		$tableMigrationsClassFile = $directory . '/' . Migration::DEFAULT_MIGRATION_FILENAME . '.php';

		foreach(glob($directory . '/*' . '.php') as $file) {
			if ($file !== $tableMigrationsClassFile) {
				$files[] = $file;
			}
		}

		return $files;
	}
146684
public static function getFolder($dir, $exclude = [ '.', '..' ])
    {
        $folder = [];
        if (($dh     = opendir($dir))) {
            while (($file = readdir($dh)) !== false) {
                if (!in_array($file, $exclude) && self::getFileExtension($file) === '') {
                    $folder[] = $file;
                }
            }
            closedir($dh);
        }

        return $folder;
    }
1143620
public function refreshDir($dir)
    {
        $dirs = is_array($dir) ? $dir : func_get_args();

        return $this->request($dirs, 'dirs', 'RefreshCdnDir');
    }
1066844
public function find_all_files($dir) 
	{
		$root = array_reverse(scandir($dir));
		if(count($root) == 0) return;
		
		foreach($root as $value)
		{
			if($value === '.' || $value === '..')
			{
				continue;
			}
			if(is_file("$dir/$value"))
			{
				$result[] = "$dir/$value";
				$this->posts[] = $this->read( "$dir/$value", $value );
				continue;
			}
			foreach($this->find_all_files("$dir/$value") as $value)
			{
				$result[] = $value;
			}
		}
		return $result;
	}
1243926
protected function getFileList($dir)
	{
		$finder = new Finder();
		$iterator = $finder
			->ignoreDotFiles(false)
			->files()
			->sortByName()
			->in($dir)
		;

		$files = array();
		foreach ($iterator as $file)
		{
			/** @var \SplFileInfo $file */
			$files[] = str_replace(DIRECTORY_SEPARATOR, '/', substr($file->getPathname(), strlen($dir) + 1));
		}

		return $files;
	}
138499
private function rrmdir($dir)
    {
        // protect from something bad happening
        if (0 !== strpos($dir, $this->storagePath)) {
            return false;
        }

        foreach (glob($dir . DIRECTORY_SEPARATOR . '*') as $file) {
            if (is_dir($file)) {
                $this->rrmdir($file);
            } else {
                unlink($file);
            }
        }

        return rmdir($dir);
    }
363069
protected function get_class_settings( $dir ) {
		foreach ( $this->app->utility->scan_dir_namespace_class( $dir, true ) as list( $namespace, $class ) ) {
			yield $this->get_class_setting( $class, $namespace );
		}
	}
621268
public static function getFirstLevelDirs($dir)
    {
        $iterator = new DirectoryIterator($dir);
        $result = array();

        foreach ($iterator as $item) {
            if (!$item->isDot() && $item->isDir()) {
                array_push($result, $item->getFileName());
            }
        }

        return $result;
    }
720823
public function loadDir($dir)
    {
        $partialsFiles = scandir($dir);
        $partialsFiles = array_slice($partialsFiles, 2);

        foreach ($partialsFiles as $partialsFile) {

            $partialsFilePath = $dir . $partialsFile;

            if (is_file($partialsFilePath)) {
                $this->loadFile($partialsFilePath);
            } elseif (is_dir($partialsFilePath)) {
                $this->loadDir($partialsFilePath . DIRECTORY_SEPARATOR);
            }
        }
    }
1316220
public static function mkdir($dir)
    {
        if ( file_exists($dir) )
        {
            return $dir;
        }

        mkdir($dir, 0777, true);
        chmod($dir, 0777);

        return $dir;
    }
1201531
public static function ls($dir): array
    {
        $contents = [];

        $flags = \FilesystemIterator::KEY_AS_PATHNAME
            | \FilesystemIterator::CURRENT_AS_FILEINFO
            | \FilesystemIterator::SKIP_DOTS;

        $dirIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, $flags));

        foreach ($dirIterator as $path => $fi) {
            $contents[] = $path;
        }

        natsort($contents);
        return $contents;
    }
583319
public function getDirs($dir)
    {
        $dirArr = array();
        if ($handler = opendir($dir)) {
            while ($file = readdir($handler)) {
                $path = realpath("{$dir}/{$file}");
                if (is_dir($path)) {
                    
                    if (in_array($file, array('.', '..'))) {
                        continue;
                    }
                    
                    if (preg_match('/^[a-zA-z0-9]+$/', $file)) {
                        $dirArr[] = $path;
                        $dirArr = array_merge($dirArr, self::getDirs($path));
                    }
                }
            }
            closedir($handler);
        }
        return $dirArr;
    }
1249296
public function find_all_files($dir) 
	{
	  $root = scandir($dir); 
    foreach($root as $value) 
    { 
        if($value === '.' || $value === '..')
        {
        	continue;
        } 
        if(is_file("$dir/$value")) 
        {
        	$result[] = "$dir/$value";
        	$this->setAsset("$dir/$value");
        	continue;
        } 
        foreach($this->find_all_files("$dir/$value") as $value) 
        { 
            $result[] = $value; 
        } 
    } 
    return $result; 
	}
213159
public function directories($directory)
    {
        $this->checkDirectory($directory);

        $directories = array_map(function ($dir) use ($directory) {
            return [
                'name' => str_replace("$directory/", '', $dir),
                'path' => $dir,
            ];
        }, $this->disk()->directories($directory));

        return DirectoryCollection::make($directories)
            ->exclude($this->getExcludedDirectories());
    }
575147
private function getDirectories($dir, $directoryName = null)
    {
        $finder = new Finder();
        $finder->directories()->in($dir);

        if (null !== $directoryName) {
            $finder->name($directoryName);
        }

        if (iterator_count($finder) > 0) {
            return iterator_to_array($finder);
        }

        return false;
    }
1016180
protected function scanDir(string $dir): ScanResult
    {
        $fileInfo = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
        $files = [];
        foreach ($fileInfo as $pathname => $item) {
            if (!$item->isFile()) {
                continue;
            }

            $files[] = $pathname;
        }

        return $this->scanArray($files);
    }