When opening ROMs, ignore error messages in certain cases.

This commit is contained in:
Stephen Anthony 2022-04-16 21:52:10 -02:30
parent fcc5fbf439
commit 97487cdaef
2 changed files with 10 additions and 5 deletions

View File

@ -753,7 +753,7 @@ ByteBuffer OSystem::openROM(const FilesystemNode& rom, string& md5, size_t& size
// but also adds a properties entry if the one for the ROM doesn't // but also adds a properties entry if the one for the ROM doesn't
// contain a valid name // contain a valid name
ByteBuffer image = openROM(rom, size); ByteBuffer image = openROM(rom, size, true); // handle error message here
if(image) if(image)
{ {
// If we get to this point, we know we have a valid file to open // If we get to this point, we know we have a valid file to open
@ -773,13 +773,14 @@ ByteBuffer OSystem::openROM(const FilesystemNode& rom, string& md5, size_t& size
string OSystem::getROMMD5(const FilesystemNode& rom) const string OSystem::getROMMD5(const FilesystemNode& rom) const
{ {
size_t size = 0; size_t size = 0;
const ByteBuffer image = openROM(rom, size); const ByteBuffer image = openROM(rom, size, false); // ignore error message
return image ? MD5::hash(image, size) : EmptyString; return image ? MD5::hash(image, size) : EmptyString;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ByteBuffer OSystem::openROM(const FilesystemNode& rom, size_t& size) const ByteBuffer OSystem::openROM(const FilesystemNode& rom, size_t& size,
bool showErrorMessage) const
{ {
// First check if this is a 'streaming' ROM (one where we only read // First check if this is a 'streaming' ROM (one where we only read
// a portion of the file) // a portion of the file)
@ -797,7 +798,8 @@ ByteBuffer OSystem::openROM(const FilesystemNode& rom, size_t& size) const
} }
catch(const runtime_error& e) catch(const runtime_error& e)
{ {
cerr << "ERROR: Couldn't open ROM (" << e.what() << ")"; if(showErrorMessage) // If caller wants error messages, pass it back
throw;
} }
return image; return image;

View File

@ -623,10 +623,13 @@ class OSystem
@param romfile The file node of the ROM to open (contains path) @param romfile The file node of the ROM to open (contains path)
@param size The amount of data read into the image array @param size The amount of data read into the image array
@param showErrorMessage Whether to show (or ignore) any errors
when opening the ROM
@return Unique pointer to the array, otherwise nullptr @return Unique pointer to the array, otherwise nullptr
*/ */
ByteBuffer openROM(const FilesystemNode& romfile, size_t& size) const; ByteBuffer openROM(const FilesystemNode& romfile, size_t& size,
bool showErrorMessage) const;
/** /**
Creates an actual Console object based on the given info. Creates an actual Console object based on the given info.