static public function generateFilename($directory, $extension, $length = 16)
    {
        do {
            $name = \Extlib\Generator::generate($length);
            $filepath = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . sprintf('%s.%s', $name, $extension);
        } while (file_exists($filepath));

        return $name;
    }