From 71bea524198424f466bf17b09afa15b6f22a63b7 Mon Sep 17 00:00:00 2001 From: tomcw Date: Thu, 15 Jul 2021 19:23:01 +0100 Subject: [PATCH] Disk/Harddisk: Insert() - fix comment and rename var --- source/Disk.cpp | 14 +++++++------- source/Disk.h | 2 +- source/Harddisk.cpp | 16 ++++++++-------- source/Harddisk.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 6ee702ac..39ed0d0c 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -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); diff --git a/source/Disk.h b/source/Disk.h index 24612c19..484e5adf 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -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); diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index c84c1202..ae55f048 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -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(); } diff --git a/source/Harddisk.h b/source/Harddisk.h index 0faa768e..61df86b1 100644 --- a/source/Harddisk.h +++ b/source/Harddisk.h @@ -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);