";
// If the directory isn't set or it's not a directory, prompt the user to enter a directory and set which type it is
if (trim($dir) == "" || !is_dir($dir))
{
echo <<Enter a directory name: Select rom type:
EOL;
foreach ($types as $typename => $val)
{
echo "\t".$typename." \n";
}
echo <<
EOL;
}
// If a directory is given but the type isn't defined or it's incorrect, give the options for file type
elseif (trim($type) == "" || !$types[$type] === "")
{
echo <<Select rom type:
EOL;
foreach ($types as $typename => $val)
{
echo "\t".$typename." \n";
}
echo <<
EOL;
}
// Otherwise, process the folder
else
{
$dir = $dir."/";
$roms = scandir($dir);
echo "