diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index e18173b..de7699a 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -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;