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