void DM::DiskMaster::ProcessDetectInfo( DM_DETECT_INFO &di, BYTE task_code ) { DMDisk *disk = NULL; ULONGLONG size = 0; if ((task_code == kTaskUsb1Sata1Copy) || (task_code == kTaskUsb1Usb2Copy) || (task_code == kTaskUsb1Read)) { memcpy(&size, &di.usb1_num_lba, sizeof(di.usb1_num_lba)); if (size && di.usb1_block_size) { disk = new DMDisk(&ports[kUsb1], &di.usb1_id, size, di.usb1_block_size); if (disks[kUsb1] == NULL) AddDisk(disk, kUsb1); else { if (*disks[kUsb1] == *disk) delete disk; else { RemoveDisk(kUsb1); AddDisk(disk, kUsb1); } } } } if ((task_code == kTaskUsb1Usb2Copy) || (task_code == kTaskUsb2Read) || (task_code == kTaskUsb2_00_Erase) || (task_code == kTaskUsb2_FF_Erase) || (task_code == kTaskUsb2_Random_Erase)) { size = 0; memcpy(&size, &di.usb2_num_lba, sizeof(di.usb2_num_lba)); if (size && di.usb2_block_size) { disk = new DMDisk(&ports[kUsb2], &di.usb2_id, size, di.usb2_block_size); if (disks[kUsb2] == NULL) AddDisk(disk, kUsb2); else { if (*disks[kUsb2] == *disk) delete disk; else { RemoveDisk(kUsb2); AddDisk(disk, kUsb2); } } } } if ((task_code == kTaskUsb1Sata1Copy) || (task_code == kTaskSata1Read) || (task_code == kTaskSata1Verify) || (task_code == kTaskSata1_00_Erase) || (task_code == kTaskSata1_FF_Erase) || (task_code == kTaskSata1_Random_Erase)) { size = 0; memcpy(&size, &di.sata1_native_max, sizeof(di.sata1_native_max)); disk = new DMDisk(&ports[kSata1], &di.sata1_id, size); if (disk->Size() && disk->BlockSize()) { if (disks[kSata1] == NULL) AddDisk(disk, kSata1); else { if (*disks[kSata1] == *disk) delete disk; else { RemoveDisk(kSata1); AddDisk(disk, kSata1); } } } else delete disk; } }
void Disk2InterfaceCard::Destroy(void) { m_saveDiskImage = false; RemoveDisk(DRIVE_1); m_saveDiskImage = false; RemoveDisk(DRIVE_2); m_saveDiskImage = true; }
void Disk2InterfaceCard::EjectDisk(const int drive) { if (IsDriveValid(drive)) { RemoveDisk(drive); } }
ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) { FloppyDrive* pDrive = &m_floppyDrive[drive]; FloppyDisk* pFloppy = &pDrive->m_disk; if (pFloppy->m_imagehandle) RemoveDisk(drive); // Reset the disk's attributes, but preserve the drive's attributes (GH#138/Platoon, GH#640) // . Changing the disk (in the drive) doesn't affect the drive's attributes. pFloppy->clear(); const DWORD dwAttributes = GetFileAttributes(pszImageFilename); if(dwAttributes == INVALID_FILE_ATTRIBUTES) pFloppy->m_bWriteProtected = false; // Assume this is a new file to create else pFloppy->m_bWriteProtected = bForceWriteProtected ? true : (dwAttributes & FILE_ATTRIBUTE_READONLY); // Check if image is being used by the other drive, and if so remove it in order so it can be swapped { const char* pszOtherPathname = DiskGetFullPathName(!drive); char szCurrentPathname[MAX_PATH]; DWORD uNameLen = GetFullPathName(pszImageFilename, MAX_PATH, szCurrentPathname, NULL); if (uNameLen == 0 || uNameLen >= MAX_PATH) strcpy_s(szCurrentPathname, MAX_PATH, pszImageFilename); if (!strcmp(pszOtherPathname, szCurrentPathname)) { EjectDisk(!drive); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } } ImageError_e Error = ImageOpen(pszImageFilename, &pFloppy->m_imagehandle, &pFloppy->m_bWriteProtected, bCreateIfNecessary, pFloppy->m_strFilenameInZip); if (Error == eIMAGE_ERROR_NONE && ImageIsMultiFileZip(pFloppy->m_imagehandle)) { TCHAR szText[100+MAX_PATH]; szText[sizeof(szText)-1] = 0; _snprintf(szText, sizeof(szText)-1, "Only the first file in a multi-file zip is supported\nUse disk image '%s' ?", pFloppy->m_strFilenameInZip.c_str()); int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Multi-Zip Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); if (nRes == IDNO) { RemoveDisk(drive); Error = eIMAGE_ERROR_REJECTED_MULTI_ZIP; } } if (Error == eIMAGE_ERROR_NONE) { GetImageTitle(pszImageFilename, pFloppy->m_imagename, pFloppy->m_fullname); Video_ResetScreenshotCounter(pFloppy->m_imagename); } else { Video_ResetScreenshotCounter(NULL); } SaveLastDiskImage(drive); return Error; }
void DM::DiskMaster::RemoveAllDisks( void ) { for (BYTE port = 0; port < kPortsCount; port++) RemoveDisk(port); }