// imagefilename is qualified with path BOOL HD_InsertDisk(int nDrive, LPCTSTR imagefilename) { if (*imagefilename == 0x00) return false; if (g_HardDrive[nDrive].hd_imageloaded) HD_CleanupDrive(nDrive); BOOL result = HD_Load_Image(nDrive, imagefilename); if (result) GetImageTitle(imagefilename, &g_HardDrive[nDrive]); return result; }
// pszImageFilename is qualified with path BOOL HD_InsertDisk(const int iDrive, LPCTSTR pszImageFilename) { if (*pszImageFilename == 0x00) return false; if (g_HardDisk[iDrive].hd_imageloaded) HD_CleanupDrive(iDrive); BOOL bResult = HD_Load_Image(iDrive, pszImageFilename); if (bResult) GetImageTitle(pszImageFilename, &g_HardDisk[iDrive]); return bResult; }
// imagefilename is qualified with path BOOL HD_InsertDisk(int nDrive, LPCTSTR imagefilename) { if (*imagefilename == 0x00) return false; if (g_HardDrive[nDrive].hd_imageloaded) HD_CleanupDrive(nDrive); BOOL result = HD_Load_Image(nDrive, imagefilename); if (result) GetImageTitle(imagefilename, &g_HardDrive[nDrive]); else NotifyInvalidImage((char*)imagefilename); // could not load hd image return result; }
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; }