Disk/Harddisk: Insert() - fix comment and rename var

This commit is contained in:
tomcw 2021-07-15 19:23:01 +01:00
parent 4f45202baf
commit 71bea52419
4 changed files with 17 additions and 17 deletions

View File

@ -654,8 +654,8 @@ void Disk2InterfaceCard::GetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status
//===========================================================================
// Pre: pszImageFilename is *not* qualified with path
ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary)
// Pre: pathname likely to include path (but can also just be filename)
ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, const std::string& pathname, const bool bForceWriteProtected, const bool bCreateIfNecessary)
{
FloppyDrive* pDrive = &m_floppyDrive[drive];
FloppyDisk* pFloppy = &pDrive->m_disk;
@ -667,7 +667,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
// . Changing the disk (in the drive) doesn't affect the drive's attributes.
pFloppy->clear();
const DWORD dwAttributes = GetFileAttributes(pszImageFilename);
const DWORD dwAttributes = GetFileAttributes(pathname.c_str());
if (dwAttributes == INVALID_FILE_ATTRIBUTES)
pFloppy->m_bWriteProtected = false; // Assume this is a new file to create (so it must be write-enabled to allow it to be formatted)
else
@ -678,9 +678,9 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
const std::string & pszOtherPathname = DiskGetFullPathName(!drive);
char szCurrentPathname[MAX_PATH];
DWORD uNameLen = GetFullPathName(pszImageFilename, MAX_PATH, szCurrentPathname, NULL);
DWORD uNameLen = GetFullPathName(pathname.c_str(), MAX_PATH, szCurrentPathname, NULL);
if (uNameLen == 0 || uNameLen >= MAX_PATH)
strcpy_s(szCurrentPathname, MAX_PATH, pszImageFilename);
strcpy_s(szCurrentPathname, MAX_PATH, pathname.c_str());
if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname))
{
@ -689,7 +689,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
}
}
ImageError_e Error = ImageOpen(pszImageFilename,
ImageError_e Error = ImageOpen(pathname,
&pFloppy->m_imagehandle,
&pFloppy->m_bWriteProtected,
bCreateIfNecessary,
@ -709,7 +709,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
if (Error == eIMAGE_ERROR_NONE)
{
GetImageTitle(pszImageFilename, pFloppy->m_imagename, pFloppy->m_fullname);
GetImageTitle(pathname.c_str(), pFloppy->m_imagename, pFloppy->m_fullname);
Snapshot_UpdatePath();
GetFrame().Video_ResetScreenshotCounter(pFloppy->m_imagename);

View File

@ -142,7 +142,7 @@ public:
void GetFilenameAndPathForSaveState(std::string& filename, std::string& path);
void GetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status);
ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary);
ImageError_e InsertDisk(const int drive, const std::string& pathname, const bool bForceWriteProtected, const bool bCreateIfNecessary);
void EjectDisk(const int drive);
void UnplugDrive(const int drive);

View File

@ -207,7 +207,7 @@ static void NotifyInvalidImage(TCHAR* pszImageFilename)
//===========================================================================
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename);
BOOL HD_Insert(const int iDrive, const std::string& pathname);
void HD_LoadLastDiskImage(const int iDrive)
{
@ -384,10 +384,10 @@ void HD_Destroy(void)
g_bSaveDiskImage = true;
}
// Pre: pszImageFilename is qualified with path
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
// Pre: pathname likely to include path (but can also just be filename)
BOOL HD_Insert(const int iDrive, const std::string& pathname)
{
if (pszImageFilename.empty())
if (pathname.empty())
return FALSE;
if (g_HardDisk[iDrive].hd_imageloaded)
@ -398,9 +398,9 @@ BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
const std::string & pszOtherPathname = HD_GetFullPathName(!iDrive);
char szCurrentPathname[MAX_PATH];
DWORD uNameLen = GetFullPathName(pszImageFilename.c_str(), MAX_PATH, szCurrentPathname, NULL);
DWORD uNameLen = GetFullPathName(pathname.c_str(), MAX_PATH, szCurrentPathname, NULL);
if (uNameLen == 0 || uNameLen >= MAX_PATH)
strcpy_s(szCurrentPathname, MAX_PATH, pszImageFilename.c_str());
strcpy_s(szCurrentPathname, MAX_PATH, pathname.c_str());
if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname))
{
@ -412,7 +412,7 @@ BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
const bool bCreateIfNecessary = false; // NB. Don't allow creation of HDV files
const bool bExpectFloppy = false;
const bool bIsHarddisk = true;
ImageError_e Error = ImageOpen(pszImageFilename,
ImageError_e Error = ImageOpen(pathname,
&g_HardDisk[iDrive].imagehandle,
&g_HardDisk[iDrive].bWriteProtected,
bCreateIfNecessary,
@ -428,7 +428,7 @@ BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
if (Error == eIMAGE_ERROR_NONE)
{
GetImageTitle(pszImageFilename.c_str(), g_HardDisk[iDrive].imagename, g_HardDisk[iDrive].fullname);
GetImageTitle(pathname.c_str(), g_HardDisk[iDrive].imagename, g_HardDisk[iDrive].fullname);
Snapshot_UpdatePath();
}

View File

@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
void HD_Reset(void);
void HD_Load_Rom(const LPBYTE pCxRomPeripheral, const UINT uSlot);
bool HD_Select(const int iDrive);
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename);
BOOL HD_Insert(const int iDrive, const std::string& pathname);
void HD_Unplug(const int iDrive);
bool HD_IsDriveUnplugged(const int iDrive);
void HD_LoadLastDiskImage(const int iDrive);