library/Extlib/FileManager.php
static public function generateDir($directory, $length = 8)
    {
        do {
            $name = \Extlib\Generator::generate($length);
            $filepath = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
        } while (is_dir($filepath));

        return $name;
    }
static public function generateDir($directory, $length = 8)
    {
        do {
            $name = \Extlib\Generator::generate($length);
            $filepath = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
        } while (is_dir($filepath));

        return $name;
    }
Generate directory

@param $directory
@param int $length
@return string