CDROM: Fix physical disc reading without SubQ on Linux

This commit is contained in:
Stenzek 2024-12-10 02:28:02 +10:00
parent 2e6deca76f
commit 1e839224e8
No known key found for this signature in database

View File

@ -123,8 +123,8 @@ std::unique_ptr<CDROMSubQReplacement> CDROMSubQReplacement::LoadLSD(const std::s
return ret; return ret;
} }
bool CDROMSubQReplacement::LoadForImage(std::unique_ptr<CDROMSubQReplacement>* ret, CDImage* image, std::string_view serial, bool CDROMSubQReplacement::LoadForImage(std::unique_ptr<CDROMSubQReplacement>* ret, CDImage* image,
std::string_view title, Error* error) std::string_view serial, std::string_view title, Error* error)
{ {
struct FileLoader struct FileLoader
{ {
@ -140,13 +140,19 @@ bool CDROMSubQReplacement::LoadForImage(std::unique_ptr<CDROMSubQReplacement>* r
std::string path; std::string path;
// Try sbi/lsd in the directory first. // Try sbi/lsd in the directory first.
for (const FileLoader& loader : loaders) if (!CDImage::IsDeviceName(image_path.c_str()))
{ {
path = Path::ReplaceExtension(image_path, loader.extension); for (const FileLoader& loader : loaders)
if (FileSystem::FileExists(path.c_str()))
{ {
*ret = loader.func(path, error); path = Path::ReplaceExtension(image_path, loader.extension);
return static_cast<bool>(*ret); if (FileSystem::FileExists(path.c_str()))
{
*ret = loader.func(path, error);
if (!static_cast<bool>(*ret))
Error::AddPrefixFmt(error, "Failed to load subchannel data from {}: ", Path::GetFileName(path));
return static_cast<bool>(*ret);
}
} }
} }
@ -161,6 +167,9 @@ bool CDROMSubQReplacement::LoadForImage(std::unique_ptr<CDROMSubQReplacement>* r
if (FileSystem::FileExists(path.c_str())) if (FileSystem::FileExists(path.c_str()))
{ {
*ret = loader.func(path, error); *ret = loader.func(path, error);
if (!static_cast<bool>(*ret))
Error::AddPrefixFmt(error, "Failed to load subchannel data from {}: ", Path::GetFileName(path));
return static_cast<bool>(*ret); return static_cast<bool>(*ret);
} }
} }
@ -175,6 +184,9 @@ bool CDROMSubQReplacement::LoadForImage(std::unique_ptr<CDROMSubQReplacement>* r
if (FileSystem::FileExists(path.c_str())) if (FileSystem::FileExists(path.c_str()))
{ {
*ret = loader.func(path, error); *ret = loader.func(path, error);
if (!static_cast<bool>(*ret))
Error::AddPrefixFmt(error, "Failed to load subchannel data from {}: ", Path::GetFileName(path));
return static_cast<bool>(*ret); return static_cast<bool>(*ret);
} }
} }
@ -188,6 +200,9 @@ bool CDROMSubQReplacement::LoadForImage(std::unique_ptr<CDROMSubQReplacement>* r
if (FileSystem::FileExists(path.c_str())) if (FileSystem::FileExists(path.c_str()))
{ {
*ret = loader.func(path, error); *ret = loader.func(path, error);
if (!static_cast<bool>(*ret))
Error::AddPrefixFmt(error, "Failed to load subchannel data from {}: ", Path::GetFileName(path));
return static_cast<bool>(*ret); return static_cast<bool>(*ret);
} }
} }