naomi: fix gdrom searching in rom parent path
OpenDisc() now throws so exceptions must be caught Never return null from OpenDisc
This commit is contained in:
parent
d4a02e3c2b
commit
56517b027a
|
@ -495,18 +495,32 @@ void GDCartridge::device_start(LoadProgress *progress, std::vector<u8> *digest)
|
|||
std::string parent = hostfs::storage().getParentPath(settings.content.path);
|
||||
std::string gdrom_path = get_file_basename(settings.content.fileName) + "/" + gdrom_name;
|
||||
gdrom_path = hostfs::storage().getSubPath(parent, gdrom_path);
|
||||
std::unique_ptr<Disc> gdrom = std::unique_ptr<Disc>(OpenDisc(gdrom_path + ".chd", digest));
|
||||
if (gdrom == nullptr)
|
||||
std::unique_ptr<Disc> gdrom;
|
||||
try {
|
||||
gdrom = std::unique_ptr<Disc>(OpenDisc(gdrom_path + ".chd", digest));
|
||||
}
|
||||
catch (const FlycastException& e)
|
||||
{
|
||||
try {
|
||||
gdrom = std::unique_ptr<Disc>(OpenDisc(gdrom_path + ".gdi", digest));
|
||||
if (gdrom_parent_name != nullptr && gdrom == nullptr)
|
||||
}
|
||||
catch (const FlycastException& e)
|
||||
{
|
||||
if (gdrom_parent_name != nullptr)
|
||||
{
|
||||
std::string gdrom_parent_path = hostfs::storage().getSubPath(parent, std::string(gdrom_parent_name) + "/" + gdrom_name);
|
||||
try {
|
||||
gdrom = std::unique_ptr<Disc>(OpenDisc(gdrom_parent_path + ".chd", digest));
|
||||
if (gdrom == nullptr)
|
||||
} catch (const FlycastException& e) {
|
||||
try {
|
||||
gdrom = std::unique_ptr<Disc>(OpenDisc(gdrom_parent_path + ".gdi", digest));
|
||||
} catch (const FlycastException& e) {}
|
||||
}
|
||||
}
|
||||
if (gdrom == nullptr)
|
||||
throw NaomiCartException("Naomi GDROM: Cannot open " + gdrom_path + ".chd or " + gdrom_path + ".gdi");
|
||||
}
|
||||
}
|
||||
|
||||
// primary volume descriptor
|
||||
// read frame 0xb06e (frame=sector+150)
|
||||
|
|
|
@ -90,7 +90,7 @@ Disc* OpenDisc(const std::string& path, std::vector<u8> *digest)
|
|||
return disc;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
throw FlycastException("Unknown disk format");
|
||||
}
|
||||
|
||||
static bool loadDisk(const std::string& path)
|
||||
|
|
Loading…
Reference in New Issue