mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-24 12:30:20 +00:00
Updated error handling
This commit is contained in:
parent
4a4cf12bca
commit
12cafe7ff5
@ -20,6 +20,7 @@
|
||||
#include "os.h"
|
||||
#include "xm6.h"
|
||||
#include "controllers/sasidev_ctrl.h"
|
||||
#include "exceptions.h"
|
||||
#include "disk.h"
|
||||
#include <sstream>
|
||||
|
||||
@ -1750,10 +1751,12 @@ int Disk::GetSectorSizeInBytes() const
|
||||
return disk.size ? 1 << disk.size : 0;
|
||||
}
|
||||
|
||||
bool Disk::SetSectorSizeInBytes(int size, bool sasi)
|
||||
void Disk::SetSectorSizeInBytes(int size, bool sasi)
|
||||
{
|
||||
if (sasi && size != 256 && size != 1024) {
|
||||
return false;
|
||||
stringstream error;
|
||||
error << "Invalid sector size of " << size << " bytes";
|
||||
throw io_exception(error.str());
|
||||
}
|
||||
|
||||
switch (size) {
|
||||
@ -1778,12 +1781,11 @@ bool Disk::SetSectorSizeInBytes(int size, bool sasi)
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
disk.size = 9;
|
||||
stringstream error;
|
||||
error << "Invalid sector size of " << size << " bytes";
|
||||
throw io_exception(error.str());
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int Disk::GetSectorSize() const
|
||||
|
@ -124,7 +124,7 @@ public:
|
||||
int SelectCheck10(const DWORD *cdb); // SELECT(10) check
|
||||
|
||||
int GetSectorSizeInBytes() const;
|
||||
bool SetSectorSizeInBytes(int, bool);
|
||||
void SetSectorSizeInBytes(int, bool);
|
||||
int GetSectorSize() const;
|
||||
bool IsSectorSizeConfigurable() const;
|
||||
vector<int> GetSectorSizes() const;
|
||||
|
@ -70,12 +70,7 @@ void SASIHD::Open(const Filepath& path)
|
||||
fio.Close();
|
||||
|
||||
// Sector size (default 256 bytes) and number of blocks
|
||||
if (!SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 256, true)) {
|
||||
stringstream error;
|
||||
error << "Invalid sector size " << GetConfiguredSectorSize();
|
||||
throw io_exception(error.str());
|
||||
|
||||
}
|
||||
SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 256, true);
|
||||
SetBlockCount((DWORD)(size >> GetSectorSize()));
|
||||
|
||||
#if defined(REMOVE_FIXED_SASIHD_SIZE)
|
||||
|
@ -71,12 +71,7 @@ void SCSIHD::Open(const Filepath& path)
|
||||
fio.Close();
|
||||
|
||||
// Sector size (default 512 bytes) and number of blocks
|
||||
if (!SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 512, false)) {
|
||||
stringstream error;
|
||||
error << "Invalid sector size " << GetConfiguredSectorSize();
|
||||
throw io_exception(error.str());
|
||||
|
||||
}
|
||||
SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 512, false);
|
||||
SetBlockCount((DWORD)(size >> GetSectorSize()));
|
||||
|
||||
// File size must be a multiple of the sector size
|
||||
|
Loading…
Reference in New Issue
Block a user