mirror of https://github.com/PCSX2/pcsx2.git
CDVD: Remove exceptions
This commit is contained in:
parent
957ec1d3d3
commit
553a5cc455
|
@ -430,9 +430,7 @@ bool DoCDVDopen()
|
|||
|
||||
Host::AddKeyedOSDMessage("BlockDumpCreate", fmt::format("Saving CDVD block dump to '{}'.", temp), Host::OSD_INFO_DURATION);
|
||||
|
||||
blockDumpFile.Create(std::move(temp), 2);
|
||||
|
||||
if (blockDumpFile.IsOpened())
|
||||
if (blockDumpFile.Create(std::move(temp), 2))
|
||||
{
|
||||
int blockofs = 0;
|
||||
uint blocksize = CD_FRAMESIZE_RAW;
|
||||
|
|
|
@ -51,15 +51,8 @@ s32 CALLBACK ISOopen(const char* pTitle)
|
|||
return -1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
iso.Open(pTitle);
|
||||
}
|
||||
catch (BaseException& ex)
|
||||
{
|
||||
Console.Error(ex.FormatDiagnosticMessage());
|
||||
if (!iso.Open(pTitle))
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (iso.GetType())
|
||||
{
|
||||
|
|
|
@ -15,14 +15,15 @@
|
|||
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "IsoFileFormats.h"
|
||||
|
||||
#include "CDVD/IsoFileFormats.h"
|
||||
#include "Config.h"
|
||||
#include "Host.h"
|
||||
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Exceptions.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include "fmt/core.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include "fmt/format.h"
|
||||
|
||||
static const char* nameFromType(int type)
|
||||
{
|
||||
|
@ -246,12 +247,17 @@ bool InputIsoFile::Open(std::string srcfile, bool testOnly)
|
|||
bool detected = Detect();
|
||||
|
||||
if (testOnly)
|
||||
{
|
||||
Close();
|
||||
return detected;
|
||||
}
|
||||
|
||||
if (!detected)
|
||||
throw Exception::BadStream()
|
||||
.SetUserMsg("Unrecognized ISO image file format.")
|
||||
.SetDiagMsg("ISO mounting failed: PCSX2 is unable to identify the ISO image type.");
|
||||
{
|
||||
Host::ReportErrorAsync("Unrecognized ISO image file format", "ISO mounting failed: PCSX2 is unable to identify the ISO image type.");
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isBlockdump && !isCompressed)
|
||||
{
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
return m_filename;
|
||||
}
|
||||
|
||||
void Create(std::string filename, int mode);
|
||||
bool Create(std::string filename, int mode);
|
||||
void Close();
|
||||
|
||||
void WriteHeader(int blockofs, uint blocksize, uint blocks);
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "IsoFileFormats.h"
|
||||
#include "CDVD/IsoFileFormats.h"
|
||||
#include "Host.h"
|
||||
|
||||
#include "common/Exceptions.h"
|
||||
#include "common/FileSystem.h"
|
||||
#include "common/StringUtil.h"
|
||||
|
@ -44,7 +46,7 @@ void OutputIsoFile::_init()
|
|||
m_blocks = 0;
|
||||
}
|
||||
|
||||
void OutputIsoFile::Create(std::string filename, int version)
|
||||
bool OutputIsoFile::Create(std::string filename, int version)
|
||||
{
|
||||
Close();
|
||||
m_filename = std::move(filename);
|
||||
|
@ -57,11 +59,13 @@ void OutputIsoFile::Create(std::string filename, int version)
|
|||
m_outstream = FileSystem::OpenCFile(m_filename.c_str(), "wb");
|
||||
if (!m_outstream)
|
||||
{
|
||||
Console.Error("(OutputIsoFile::Create) Unable to open the file '%s' for writing: %d", m_filename.c_str(), errno);
|
||||
Exception::FromErrno(filename, errno)->Rethrow();
|
||||
Console.Error(fmt::format("(OutputIsoFile::Create) Unable to open the file '{}' for writing: {}", m_filename, errno));
|
||||
_init();
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLn("isoFile create ok: %s ", m_filename.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Generates format header information for blockdumps.
|
||||
|
@ -122,16 +126,8 @@ void OutputIsoFile::WriteBuffer(const void* src, size_t size)
|
|||
{
|
||||
if (std::fwrite(src, size, 1, m_outstream) != 1)
|
||||
{
|
||||
int err = errno;
|
||||
if (!err)
|
||||
{
|
||||
throw Exception::BadStream(m_filename)
|
||||
.SetDiagMsg(fmt::format("An error occurred while writing {} bytes to file", size));
|
||||
}
|
||||
|
||||
std::unique_ptr<BaseException> ex(Exception::FromErrno(m_filename, err));
|
||||
ex->SetDiagMsg(fmt::format("An error occurred while writing {} bytes to file: {}", size, ex->DiagMsg()));
|
||||
ex->Rethrow();
|
||||
Host::ReportErrorAsync("Write Error", fmt::format("errno {} when trying to write {} bytes to block dump file.\n\nClosing file."));
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue