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