Names of removable media drives must be constant and not contain the capacity

This commit is contained in:
Uwe Seimet 2021-08-28 15:06:53 +02:00
parent 1755c7e2f8
commit 93f980fd60
4 changed files with 21 additions and 19 deletions

View File

@ -82,7 +82,7 @@ Device *DeviceFactory::CreateDevice(PbDeviceType& type, const string& filename,
device = new SCSIHD_NEC();
((Disk *)device)->SetVendor("NEC");
} else {
device = new SCSIHD();
device = new SCSIHD(false);
device->SetProtectable(true);
((Disk *)device)->SetSectorSizes(sector_sizes_scsi);
}
@ -94,6 +94,7 @@ Device *DeviceFactory::CreateDevice(PbDeviceType& type, const string& filename,
device->SetRemovable(true);
device->SetLockable(true);
device->SetProtectable(true);
device->SetProduct("SCSI HD (REM.)");
((Disk *)device)->SetSectorSizes(sector_sizes_scsi);
break;

View File

@ -19,6 +19,8 @@
#include <sstream>
#include "../rascsi.h"
#define DEFAULT_PRODUCT "SCSI HD"
//===========================================================================
//
// SCSI Hard Disk
@ -32,7 +34,6 @@
//---------------------------------------------------------------------------
SCSIHD::SCSIHD(bool removable) : Disk(removable ? "SCRM" : "SCHD")
{
SetRemovable(removable);
}
//---------------------------------------------------------------------------
@ -86,20 +87,22 @@ void SCSIHD::Open(const Filepath& path)
throw io_exception("File size must not exceed 2 TB");
}
// Set the default product name based on the drive capacity
int capacity;
string unit;
if (GetBlockCount() >> 11 >= 1) {
capacity = GetBlockCount() >> 11;
unit = "MB";
// For non-removable media drives set the default product name based on the drive capacity
if (!IsRemovable()) {
int capacity;
string unit;
if (GetBlockCount() >> 11 >= 1) {
capacity = GetBlockCount() >> 11;
unit = "MB";
}
else {
capacity = GetBlockCount() >> 1;
unit = "KB";
}
stringstream product;
product << DEFAULT_PRODUCT << " " << capacity << " " << unit;
SetProduct(product.str(), false);
}
else {
capacity = GetBlockCount() >> 1;
unit = "KB";
}
stringstream product;
product << DEFAULT_PRODUCT << " " << capacity << " " << unit;
SetProduct(product.str(), false);
Disk::Open(path);
FileSupport::SetPath(path);

View File

@ -19,8 +19,6 @@
#include "disk.h"
#include "filepath.h"
#define DEFAULT_PRODUCT "SCSI HD"
//===========================================================================
//
// SCSI Hard Disk
@ -30,7 +28,7 @@ class SCSIHD : public Disk, public FileSupport
{
public:
// Basic Functions
SCSIHD(bool = false); // Constructor
SCSIHD(bool); // Constructor
void Reset(); // Reset
void Open(const Filepath& path); // Open

View File

@ -29,7 +29,7 @@
// Constructor
//
//---------------------------------------------------------------------------
SCSIHD_NEC::SCSIHD_NEC() : SCSIHD()
SCSIHD_NEC::SCSIHD_NEC() : SCSIHD(false)
{
// Work initialization
cylinders = 0;