Allow optical files that are set to RO on the SD card to be used

This commit is contained in:
Eric Helgeson 2022-12-22 08:52:34 -06:00
parent b117ebb39d
commit 208e3cdf9a
1 changed files with 25 additions and 19 deletions

View File

@ -563,32 +563,38 @@ void findDriveImages(FsFile root) {
break;
}
// Valid file, open for reading/writing.
file = new FsFile(SD.open(name, O_RDWR));
if(file && file->isFile()) {
SCSI_DEVICE_TYPE device_type;
if(tolower(name[1]) != 'd') {
file->close();
delete file;
LOG_FILE.print("Not an image: ");
LOG_FILE.println(name);
continue;
}
switch (tolower(name[0])) {
case 'h': device_type = SCSI_DEVICE_HDD;
break;
case 'c': device_type = SCSI_DEVICE_OPTICAL;
break;
if(tolower(name[1]) != 'd')
{
file->close();
delete file;
LOG_FILE.print("Not an image: ");
LOG_FILE.println(name);
continue;
}
SCSI_DEVICE_TYPE device_type;
switch (tolower(name[0]))
{
case 'h':
device_type = SCSI_DEVICE_HDD;
file = new FsFile(SD.open(name, O_RDWR));
break;
case 'c':
device_type = SCSI_DEVICE_OPTICAL;
file = new FsFile(SD.open(name, O_RDONLY));
break;
default:
file->close();
delete file;
LOG_FILE.print("Not an image: ");
LOG_FILE.println(name);
continue;
}
}
// Defaults for Hard Disks
// Valid file
if(file && file->isFile())
{
// Defaults drives
int id = 1; // 0 and 3 are common in Macs for physical HD and CD, so avoid them.
int lun = 0;
int blk = 512;