More std::strings.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2019-09-07 09:02:39 +01:00
parent d5890e8356
commit f5f60310c1
17 changed files with 114 additions and 112 deletions

View File

@ -125,7 +125,7 @@ BOOL CPageAdvanced::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPAR
case WM_INITDIALOG:
{
SendDlgItemMessage(hWnd,IDC_SAVESTATE_FILENAME,WM_SETTEXT,0,(LPARAM)Snapshot_GetFilename());
SendDlgItemMessage(hWnd,IDC_SAVESTATE_FILENAME,WM_SETTEXT,0,(LPARAM)Snapshot_GetFilename().c_str());
CheckDlgButton(hWnd, IDC_SAVESTATE_ON_EXIT, g_bSaveStateOnExit ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_DUMPTOPRINTER, g_bDumpToPrinter ? BST_CHECKED : BST_UNCHECKED);

View File

@ -134,15 +134,15 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1);
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1);
if (strlen(sg_Disk2Card.GetFullName(DRIVE_1)) > 0)
if (!sg_Disk2Card.GetFullName(DRIVE_1).empty())
{
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(DRIVE_1));
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(DRIVE_1).c_str());
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0);
}
if (strlen(sg_Disk2Card.GetFullName(DRIVE_2)) > 0)
if (!sg_Disk2Card.GetFullName(DRIVE_2).empty())
{
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(DRIVE_2));
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(DRIVE_2).c_str());
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0);
}
@ -171,15 +171,15 @@ void CPageDisk::InitComboHDD(HWND hWnd)
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD1, m_defaultHDDOptions, -1);
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD2, m_defaultHDDOptions, -1);
if (strlen(HD_GetFullName(HARDDISK_1)) > 0)
if (!HD_GetFullName(HARDDISK_1).empty())
{
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_1));
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_1).c_str());
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_SETCURSEL, 0, 0);
}
if (strlen(HD_GetFullName(HARDDISK_2)) > 0)
if (!HD_GetFullName(HARDDISK_2).empty())
{
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_2));
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_2).c_str());
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_SETCURSEL, 0, 0);
}
}
@ -199,8 +199,8 @@ void CPageDisk::DlgOK(HWND hWnd)
m_PropertySheetHelper.GetConfigNew().m_bEnableHDD = bNewHDDIsEnabled;
}
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_1), 1, HD_GetFullPathName(HARDDISK_1));
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_2), 1, HD_GetFullPathName(HARDDISK_2));
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_1), 1, HD_GetFullPathName(HARDDISK_1).c_str());
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_2), 1, HD_GetFullPathName(HARDDISK_2).c_str());
m_PropertySheetHelper.PostMsgAfterClose(hWnd, m_Page);
}
@ -255,13 +255,13 @@ void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
}
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(driveSelected));
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(driveSelected).c_str());
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
// If the HD was in the other combo, remove now
DWORD comboOther = (comboSelected == IDC_COMBO_HDD1) ? IDC_COMBO_HDD2 : IDC_COMBO_HDD1;
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)HD_GetFullName(driveSelected));
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)HD_GetFullName(driveSelected).c_str());
if (duplicated != CB_ERR)
{
SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0);
@ -316,13 +316,13 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
}
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(driveSelected));
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(driveSelected).c_str());
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
// If the FD was in the other combo, remove now
DWORD comboOther = (comboSelected == IDC_COMBO_DISK1) ? IDC_COMBO_DISK2 : IDC_COMBO_DISK1;
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)sg_Disk2Card.GetFullName(driveSelected));
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)sg_Disk2Card.GetFullName(driveSelected).c_str());
if (duplicated != CB_ERR)
{
SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0);

View File

@ -138,7 +138,7 @@ void CPropertySheetHelper::SetSlot5(SS_CARDTYPE NewCardType)
std::string CPropertySheetHelper::BrowseToFile(HWND hWindow, TCHAR* pszTitle, TCHAR* REGVALUE, TCHAR* FILEMASKS)
{
static char PathToFile[MAX_PATH] = {0}; //This is a really awkward way to prevent mixing CiderPress and SaveStated values (RAPCS), but it seem the quickest. Here is its Line 1.
strcpy(PathToFile, Snapshot_GetFilename()); //RAPCS, line 2.
strcpy(PathToFile, Snapshot_GetFilename().c_str()); //RAPCS, line 2.
TCHAR szDirectory[MAX_PATH] = TEXT("");
TCHAR szFilename[MAX_PATH];
RegLoadString(TEXT("Configuration"), REGVALUE, 1, szFilename, MAX_PATH, TEXT(""));
@ -195,53 +195,55 @@ void CPropertySheetHelper::SaveStateUpdate()
}
}
void CPropertySheetHelper::GetDiskBaseNameWithAWS(TCHAR* pszFilename)
void CPropertySheetHelper::GetDiskBaseNameWithAWS(std::string & pszFilename)
{
LPCTSTR pDiskName = sg_Disk2Card.GetBaseName(DRIVE_1);
if (pDiskName && pDiskName[0])
const std::string & pDiskName = sg_Disk2Card.GetBaseName(DRIVE_1);
if (!pDiskName.empty())
{
strcpy(pszFilename, pDiskName);
strcpy(&pszFilename[strlen(pDiskName)], ".aws.yaml");
pszFilename = pDiskName + ".aws.yaml";
}
}
// NB. OK'ing this property sheet will call Snapshot_SetFilename() with this new filename
int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bool bSave)
{
TCHAR szDirectory[MAX_PATH] = TEXT("");
TCHAR szFilename[MAX_PATH] = {0};
std::string szDirectory;
std::string szFilename;
if (bSave)
{
// Attempt to use drive1's image name as the name for the .aws file
// Else Attempt to use the Prop Sheet's filename
GetDiskBaseNameWithAWS(szFilename);
if (szFilename[0] == 0)
if (szFilename.empty())
{
strcpy(szFilename, Snapshot_GetFilename());
szFilename = Snapshot_GetFilename();
}
}
else // Load (or Browse)
{
// Attempt to use the Prop Sheet's filename first
// Else attempt to use drive1's image name as the name for the .aws file
strcpy(szFilename, Snapshot_GetFilename());
if (szFilename[0] == 0)
szFilename = Snapshot_GetFilename();
if (szFilename.empty())
{
GetDiskBaseNameWithAWS(szFilename);
}
strcpy(szDirectory, Snapshot_GetPath());
szDirectory = Snapshot_GetPath();
}
if (szDirectory[0] == 0)
strcpy(szDirectory, g_sCurrentDir);
if (szDirectory.empty())
szDirectory = g_sCurrentDir;
//
OPENFILENAME ofn;
ZeroMemory(&ofn,sizeof(OPENFILENAME));
TCHAR localFilename[MAX_PATH];
strcpy(localFilename, szFilename.c_str());
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWindow;
ofn.hInstance = g_hInstance;
@ -255,9 +257,9 @@ int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bo
ofn.lpstrFilter = TEXT("Save State files (*.aws,*.aws.yaml)\0*.aws;*.aws.yaml\0");
TEXT("All Files\0*.*\0");
}
ofn.lpstrFile = szFilename; // Dialog strips the last .EXT from this string (eg. file.aws.yaml is displayed as: file.aws
ofn.lpstrFile = localFilename; // Dialog strips the last .EXT from this string (eg. file.aws.yaml is displayed as: file.aws
ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = szDirectory;
ofn.lpstrInitialDir = szDirectory.c_str();
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrTitle = pszTitle;
@ -298,11 +300,11 @@ int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bo
}
strcpy(m_szSSNewFilename, &szFilename[ofn.nFileOffset]);
strcpy(m_szSSNewPathname, szFilename);
strcpy(m_szSSNewPathname, szFilename.c_str());
szFilename[ofn.nFileOffset] = 0;
if (_tcsicmp(szDirectory, szFilename))
strcpy(m_szSSNewDirectory, szFilename);
if (_tcsicmp(szDirectory.c_str(), szFilename.c_str()))
strcpy(m_szSSNewDirectory, szFilename.c_str());
}
m_bSSNewFilename = nRes ? true : false;

View File

@ -50,7 +50,7 @@ private:
void RestoreCurrentConfig(void);
std::string GetSlot(const UINT uSlot);
std::string GetCardName(const SS_CARDTYPE CardType);
void GetDiskBaseNameWithAWS(TCHAR* pszFilename);
void GetDiskBaseNameWithAWS(std::string & pszFilename);
PAGETYPE m_LastPage;
UINT32 m_bmPages;

View File

@ -177,7 +177,7 @@ void Disk2InterfaceCard::SaveLastDiskImage(const int drive)
if (!m_saveDiskImage)
return;
const TCHAR *pFileName = m_floppyDrive[drive].m_disk.m_fullname;
const TCHAR *pFileName = m_floppyDrive[drive].m_disk.m_fullname.c_str();
if (drive == DRIVE_1)
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_DISK_1), TRUE, pFileName);
@ -187,7 +187,7 @@ void Disk2InterfaceCard::SaveLastDiskImage(const int drive)
//
TCHAR szPathName[MAX_PATH];
StringCbCopy(szPathName, MAX_PATH, DiskGetFullPathName(drive));
StringCbCopy(szPathName, MAX_PATH, DiskGetFullPathName(drive).c_str());
TCHAR* slash = _tcsrchr(szPathName, TEXT('\\'));
if (slash != NULL)
{
@ -346,12 +346,12 @@ void Disk2InterfaceCard::RemoveDisk(const int drive)
pFloppy->m_trackimagedata = false;
}
memset( pFloppy->m_imagename, 0, MAX_DISK_IMAGE_NAME+1 );
memset( pFloppy->m_fullname , 0, MAX_DISK_FULL_NAME +1 );
pFloppy->m_imagename.clear();
pFloppy->m_fullname.clear();
pFloppy->m_strFilenameInZip = "";
SaveLastDiskImage( drive );
Video_ResetScreenshotCounter( NULL );
Video_ResetScreenshotCounter( "" );
}
//===========================================================================
@ -555,29 +555,29 @@ void Disk2InterfaceCard::EjectDisk(const int drive)
// Return the filename
// . Used by Drive Buttons' tooltips
LPCTSTR Disk2InterfaceCard::GetFullDiskFilename(const int drive)
const std::string & Disk2InterfaceCard::GetFullDiskFilename(const int drive)
{
if (!m_floppyDrive[drive].m_disk.m_strFilenameInZip.empty())
return m_floppyDrive[drive].m_disk.m_strFilenameInZip.c_str();
return m_floppyDrive[drive].m_disk.m_strFilenameInZip;
return GetFullName(drive);
}
// Return the file or zip name
// . Used by Property Sheet Page (Disk)
LPCTSTR Disk2InterfaceCard::GetFullName(const int drive)
const std::string & Disk2InterfaceCard::GetFullName(const int drive)
{
return m_floppyDrive[drive].m_disk.m_fullname;
}
// Return the imagename
// . Used by Drive Button's icons & Property Sheet Page (Save snapshot)
LPCTSTR Disk2InterfaceCard::GetBaseName(const int drive)
const std::string & Disk2InterfaceCard::GetBaseName(const int drive)
{
return m_floppyDrive[drive].m_disk.m_imagename;
}
LPCTSTR Disk2InterfaceCard::DiskGetFullPathName(const int drive)
const std::string & Disk2InterfaceCard::DiskGetFullPathName(const int drive)
{
return ImageGetPathname(m_floppyDrive[drive].m_disk.m_imagehandle);
}
@ -615,14 +615,14 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
// 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);
const std::string & 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))
if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname))
{
EjectDisk(!drive);
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
@ -654,7 +654,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
}
else
{
Video_ResetScreenshotCounter(NULL);
Video_ResetScreenshotCounter("");
}
SaveLastDiskImage(drive);

View File

@ -53,8 +53,8 @@ public:
void clear()
{
ZeroMemory(m_imagename, sizeof(m_imagename));
ZeroMemory(m_fullname, sizeof(m_fullname));
m_imagename.clear();
m_fullname.clear();
m_strFilenameInZip.clear();
m_imagehandle = NULL;
m_bWriteProtected = false;
@ -71,8 +71,8 @@ public:
}
public:
TCHAR m_imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // <FILENAME> (ie. no extension)
TCHAR m_fullname [ MAX_DISK_FULL_NAME + 1 ]; // <FILENAME.EXT> or <FILENAME.zip> : This is persisted to the snapshot file
std::string m_imagename; // <FILENAME> (ie. no extension)
std::string m_fullname; // <FILENAME.EXT> or <FILENAME.zip> : This is persisted to the snapshot file
std::string m_strFilenameInZip; // "" or <FILENAME.EXT>
ImageInfo* m_imagehandle; // Init'd by InsertDisk() -> ImageOpen()
bool m_bWriteProtected;
@ -130,9 +130,9 @@ public:
void Boot(void);
void FlushCurrentTrack(const int drive);
LPCTSTR GetFullDiskFilename(const int drive);
LPCTSTR GetFullName(const int drive);
LPCTSTR GetBaseName(const int drive);
const std::string & GetFullDiskFilename(const int drive);
const std::string & GetFullName(const int drive);
const std::string & GetBaseName(const int drive);
void GetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status);
ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary);
@ -182,7 +182,7 @@ private:
void ReadTrack(const int drive, ULONG uExecutedCycles);
void RemoveDisk(const int drive);
void WriteTrack(const int drive);
LPCTSTR DiskGetFullPathName(const int drive);
const std::string & DiskGetFullPathName(const int drive);
void ResetLogicStateSequencer(void);
void UpdateBitStreamPositionAndDiskCycle(const ULONG uExecutedCycles);
UINT GetBitCellDelta(const BYTE optimalBitTiming);

View File

@ -39,7 +39,7 @@ static CHardDiskImageHelper sg_HardDiskImageHelper;
//===========================================================================
// Pre: *pWriteProtected_ already set to file's r/w status - see DiskInsert()
ImageError_e ImageOpen( LPCTSTR pszImageFilename,
ImageError_e ImageOpen( const std::string & pszImageFilename,
ImageInfo** ppImageInfo,
bool* pWriteProtected,
const bool bCreateIfNecessary,
@ -49,7 +49,7 @@ ImageError_e ImageOpen( LPCTSTR pszImageFilename,
if (bExpectFloppy && sg_DiskImageHelper.GetWorkBuffer() == NULL)
return eIMAGE_ERROR_BAD_POINTER;
if (! (pszImageFilename && ppImageInfo && pWriteProtected))
if (! (ppImageInfo && pWriteProtected))
return eIMAGE_ERROR_BAD_POINTER;
// CREATE A RECORD FOR THE FILE
@ -63,7 +63,7 @@ ImageError_e ImageOpen( LPCTSTR pszImageFilename,
if (bExpectFloppy) pImageInfo->pImageHelper = &sg_DiskImageHelper;
else pImageInfo->pImageHelper = &sg_HardDiskImageHelper;
ImageError_e Err = pImageInfo->pImageHelper->Open(pszImageFilename, pImageInfo, bCreateIfNecessary, strFilenameInZip);
ImageError_e Err = pImageInfo->pImageHelper->Open(pszImageFilename.c_str(), pImageInfo, bCreateIfNecessary, strFilenameInZip);
if (Err != eIMAGE_ERROR_NONE)
{
ImageClose(*ppImageInfo, true);
@ -239,9 +239,9 @@ bool ImageIsMultiFileZip(ImageInfo* const pImageInfo)
return pImageInfo ? (pImageInfo->uNumEntriesInZip > 1) : false;
}
const char* ImageGetPathname(ImageInfo* const pImageInfo)
const std::string & ImageGetPathname(ImageInfo* const pImageInfo)
{
static const char* szEmpty = "";
static const std::string szEmpty;
return pImageInfo ? pImageInfo->szFilename : szEmpty;
}
@ -277,7 +277,7 @@ UINT ImagePhaseToTrack(ImageInfo* const pImageInfo, const float phase, const boo
return track;
}
void GetImageTitle(LPCTSTR pPathname, TCHAR* pImageName, TCHAR* pFullName)
void GetImageTitle(LPCTSTR pPathname, std::string & pImageName, std::string & pFullName)
{
TCHAR imagetitle[ MAX_DISK_FULL_NAME+1 ];
LPCTSTR startpos = pPathname;
@ -304,8 +304,7 @@ void GetImageTitle(LPCTSTR pPathname, TCHAR* pImageName, TCHAR* pFullName)
CharLowerBuff(imagetitle+1, _tcslen(imagetitle+1));
// pFullName = <FILENAME.EXT>
_tcsncpy( pFullName, imagetitle, MAX_DISK_FULL_NAME );
pFullName[ MAX_DISK_FULL_NAME ] = 0;
pFullName = imagetitle;
if (imagetitle[0])
{
@ -317,6 +316,5 @@ void GetImageTitle(LPCTSTR pPathname, TCHAR* pImageName, TCHAR* pFullName)
}
// pImageName = <FILENAME> (ie. no extension)
_tcsncpy( pImageName, imagetitle, MAX_DISK_IMAGE_NAME );
pImageName[ MAX_DISK_IMAGE_NAME ] = 0;
pImageName = imagetitle;
}

View File

@ -65,7 +65,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
struct ImageInfo;
ImageError_e ImageOpen(LPCTSTR pszImageFilename, ImageInfo** ppImageInfo, bool* pWriteProtected, const bool bCreateIfNecessary, std::string& strFilenameInZip, const bool bExpectFloppy=true);
ImageError_e ImageOpen(const std::string & pszImageFilename, ImageInfo** ppImageInfo, bool* pWriteProtected, const bool bCreateIfNecessary, std::string& strFilenameInZip, const bool bExpectFloppy=true);
void ImageClose(ImageInfo* const pImageInfo, const bool bOpenError=false);
BOOL ImageBoot(ImageInfo* const pImageInfo);
void ImageDestroy(void);
@ -79,10 +79,10 @@ bool ImageWriteBlock(ImageInfo* const pImageInfo, UINT nBlock, LPBYTE pBlockBuff
UINT ImageGetNumTracks(ImageInfo* const pImageInfo);
bool ImageIsWriteProtected(ImageInfo* const pImageInfo);
bool ImageIsMultiFileZip(ImageInfo* const pImageInfo);
const char* ImageGetPathname(ImageInfo* const pImageInfo);
const std::string & ImageGetPathname(ImageInfo* const pImageInfo);
UINT ImageGetImageSize(ImageInfo* const pImageInfo);
bool ImageIsWOZ(ImageInfo* const pImageInfo);
BYTE ImageGetOptimalBitTiming(ImageInfo* const pImageInfo);
UINT ImagePhaseToTrack(ImageInfo* const pImageInfo, const float phase, const bool limit=true);
void GetImageTitle(LPCTSTR pPathname, TCHAR* pImageName, TCHAR* pFullName);
void GetImageTitle(LPCTSTR pPathname, std::string & pImageName, std::string & pFullName);

View File

@ -99,7 +99,7 @@ bool CImageBase::WriteTrack(ImageInfo* pImageInfo, const int nTrack, LPBYTE pTra
else if (pImageInfo->FileType == eFileGZip)
{
// Write entire compressed image each time (dirty track change or dirty disk removal)
gzFile hGZFile = gzopen(pImageInfo->szFilename, "wb");
gzFile hGZFile = gzopen(pImageInfo->szFilename.c_str(), "wb");
if (hGZFile == NULL)
return false;
@ -116,7 +116,7 @@ bool CImageBase::WriteTrack(ImageInfo* pImageInfo, const int nTrack, LPBYTE pTra
{
// Write entire compressed image each time (dirty track change or dirty disk removal)
// NB. Only support Zip archives with a single file
zipFile hZipFile = zipOpen(pImageInfo->szFilename, APPEND_STATUS_CREATE);
zipFile hZipFile = zipOpen(pImageInfo->szFilename.c_str(), APPEND_STATUS_CREATE);
if (hZipFile == NULL)
return false;
@ -220,7 +220,7 @@ bool CImageBase::WriteBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBlo
else if (pImageInfo->FileType == eFileGZip)
{
// Write entire compressed image each time a block is written
gzFile hGZFile = gzopen(pImageInfo->szFilename, "wb");
gzFile hGZFile = gzopen(pImageInfo->szFilename.c_str(), "wb");
if (hGZFile == NULL)
return false;
@ -237,7 +237,7 @@ bool CImageBase::WriteBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBlo
{
// Write entire compressed image each time a block is written
// NB. Only support Zip archives with a single file
zipFile hZipFile = zipOpen(pImageInfo->szFilename, APPEND_STATUS_CREATE);
zipFile hZipFile = zipOpen(pImageInfo->szFilename.c_str(), APPEND_STATUS_CREATE);
if (hZipFile == NULL)
return false;
@ -1681,7 +1681,9 @@ ImageError_e CImageHelperBase::Open( LPCTSTR pszImageFilename,
if (Err != eIMAGE_ERROR_NONE)
return Err;
DWORD uNameLen = GetFullPathName(pszImageFilename, MAX_PATH, pImageInfo->szFilename, NULL);
TCHAR szFilename[MAX_PATH] = { 0 };
DWORD uNameLen = GetFullPathName(pszImageFilename, MAX_PATH, szFilename, NULL);
pImageInfo->szFilename = szFilename;
if (uNameLen == 0 || uNameLen >= MAX_PATH)
Err = eIMAGE_ERROR_FAILED_TO_GET_PATHNAME;
@ -1700,7 +1702,7 @@ void CImageHelperBase::Close(ImageInfo* pImageInfo, const bool bDeleteFile)
if (bDeleteFile)
{
DeleteFile(pImageInfo->szFilename);
DeleteFile(pImageInfo->szFilename.c_str());
}
pImageInfo->szFilename[0] = 0;

View File

@ -20,7 +20,7 @@ enum FileType_e {eFileNormal, eFileGZip, eFileZip};
struct ImageInfo
{
TCHAR szFilename[MAX_PATH];
std::string szFilename;
CImageBase* pImageType;
CImageHelperBase* pImageHelper;
FileType_e FileType;

View File

@ -513,7 +513,7 @@ static void DrawButton (HDC passdc, int number) {
SetTextColor(dc,RGB(0,0,0));
SetTextAlign(dc,TA_CENTER | TA_TOP);
SetBkMode(dc,TRANSPARENT);
LPCTSTR pszBaseName = sg_Disk2Card.GetBaseName(number-BTN_DRIVE1);
LPCTSTR pszBaseName = sg_Disk2Card.GetBaseName(number-BTN_DRIVE1).c_str();
ExtTextOut(dc,x+offset+22,rect.top,ETO_CLIPPED,&rect,
pszBaseName,
MIN(8,_tcslen(pszBaseName)),
@ -1685,7 +1685,7 @@ LRESULT CALLBACK FrameWndProc (
if(((LPNMTTDISPINFO)lparam)->hdr.hwndFrom == tooltipwindow &&
((LPNMTTDISPINFO)lparam)->hdr.code == TTN_GETDISPINFO)
((LPNMTTDISPINFO)lparam)->lpszText =
(LPTSTR)sg_Disk2Card.GetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom);
(LPTSTR)sg_Disk2Card.GetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom).c_str();
break;
case WM_PAINT:

View File

@ -123,8 +123,8 @@ struct HDD
{
// This is not a POD (there is a std::string)
// ZeroMemory does not work
ZeroMemory(imagename, sizeof(imagename));
ZeroMemory(fullname, sizeof(fullname));
imagename.clear();
fullname.clear();
strFilenameInZip.clear();
imagehandle = NULL;
bWriteProtected = false;
@ -141,8 +141,8 @@ struct HDD
}
// From FloppyDisk
TCHAR imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // <FILENAME> (ie. no extension) [not used]
TCHAR fullname[ MAX_DISK_FULL_NAME + 1 ]; // <FILENAME.EXT> or <FILENAME.zip>
std::string imagename; // <FILENAME> (ie. no extension) [not used]
std::string fullname; // <FILENAME.EXT> or <FILENAME.zip>
std::string strFilenameInZip; // "" or <FILENAME.EXT> [not used]
ImageInfo* imagehandle; // Init'd by HD_Insert() -> ImageOpen()
bool bWriteProtected; // Needed for ImageOpen() [otherwise not used]
@ -204,7 +204,7 @@ static void NotifyInvalidImage(TCHAR* pszImageFilename)
//===========================================================================
BOOL HD_Insert(const int iDrive, LPCTSTR pszImageFilename);
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename);
void HD_LoadLastDiskImage(const int iDrive)
{
@ -233,7 +233,7 @@ static void HD_SaveLastDiskImage(const int iDrive)
if (!g_bSaveDiskImage)
return;
const char *pFileName = g_HardDisk[iDrive].fullname;
const char *pFileName = g_HardDisk[iDrive].fullname.c_str();
if (iDrive == HARDDISK_1)
RegSaveString(TEXT(REG_PREFS), REGVALUE_PREF_LAST_HARDDISK_1, TRUE, pFileName);
@ -243,7 +243,7 @@ static void HD_SaveLastDiskImage(const int iDrive)
//
char szPathName[MAX_PATH];
strcpy(szPathName, HD_GetFullPathName(iDrive));
strcpy(szPathName, HD_GetFullPathName(iDrive).c_str());
if (_tcsrchr(szPathName, TEXT('\\')))
{
char* pPathEnd = _tcsrchr(szPathName, TEXT('\\'))+1;
@ -296,17 +296,17 @@ void HD_SetEnabled(const bool bEnabled)
//-------------------------------------
LPCTSTR HD_GetFullName(const int iDrive)
const std::string & HD_GetFullName(const int iDrive)
{
return g_HardDisk[iDrive].fullname;
}
LPCTSTR HD_GetFullPathName(const int iDrive)
const std::string & HD_GetFullPathName(const int iDrive)
{
return ImageGetPathname(g_HardDisk[iDrive].imagehandle);
}
static LPCTSTR HD_DiskGetBaseName(const int iDrive) // Not used
static const std::string & HD_DiskGetBaseName(const int iDrive) // Not used
{
return g_HardDisk[iDrive].imagename;
}
@ -362,9 +362,9 @@ void HD_Destroy(void)
}
// Pre: pszImageFilename is qualified with path
BOOL HD_Insert(const int iDrive, LPCTSTR pszImageFilename)
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
{
if (*pszImageFilename == 0x00)
if (pszImageFilename.empty())
return FALSE;
if (g_HardDisk[iDrive].hd_imageloaded)
@ -372,14 +372,14 @@ BOOL HD_Insert(const int iDrive, LPCTSTR pszImageFilename)
// Check if image is being used by the other HDD, and unplug it in order to be swapped
{
const char* pszOtherPathname = HD_GetFullPathName(!iDrive);
const std::string & pszOtherPathname = HD_GetFullPathName(!iDrive);
char szCurrentPathname[MAX_PATH];
DWORD uNameLen = GetFullPathName(pszImageFilename, MAX_PATH, szCurrentPathname, NULL);
DWORD uNameLen = GetFullPathName(pszImageFilename.c_str(), MAX_PATH, szCurrentPathname, NULL);
if (uNameLen == 0 || uNameLen >= MAX_PATH)
strcpy_s(szCurrentPathname, MAX_PATH, pszImageFilename);
strcpy_s(szCurrentPathname, MAX_PATH, pszImageFilename.c_str());
if (!strcmp(pszOtherPathname, szCurrentPathname))
if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname))
{
HD_Unplug(!iDrive);
FrameRefreshStatus(DRAW_LEDS);
@ -405,7 +405,7 @@ BOOL HD_Insert(const int iDrive, LPCTSTR pszImageFilename)
if (Error == eIMAGE_ERROR_NONE)
{
GetImageTitle(pszImageFilename, g_HardDisk[iDrive].imagename, g_HardDisk[iDrive].fullname);
GetImageTitle(pszImageFilename.c_str(), g_HardDisk[iDrive].imagename, g_HardDisk[iDrive].fullname);
}
HD_SaveLastDiskImage(iDrive);

View File

@ -33,12 +33,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
void HD_Destroy(void);
bool HD_CardIsEnabled(void);
void HD_SetEnabled(const bool bEnabled);
LPCTSTR HD_GetFullName(const int iDrive);
LPCTSTR HD_GetFullPathName(const int iDrive);
const std::string & HD_GetFullName(const int iDrive);
const std::string & HD_GetFullPathName(const int iDrive);
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, LPCTSTR pszImageFilename);
BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename);
void HD_Unplug(const int iDrive);
bool HD_IsDriveUnplugged(const int iDrive);
void HD_LoadLastDiskImage(const int iDrive);

View File

@ -104,14 +104,14 @@ void Snapshot_SetFilename(std::string strPathname)
g_strSaveStatePathname = strPathname;
}
const char* Snapshot_GetFilename()
const std::string & Snapshot_GetFilename()
{
return g_strSaveStateFilename.c_str();
return g_strSaveStateFilename;
}
const char* Snapshot_GetPath()
const std::string & Snapshot_GetPath()
{
return g_strSaveStatePath.c_str();
return g_strSaveStatePath;
}
//-----------------------------------------------------------------------------

View File

@ -3,8 +3,8 @@
extern bool g_bSaveStateOnExit;
void Snapshot_SetFilename(std::string strPathname);
const char* Snapshot_GetFilename();
const char* Snapshot_GetPath();
const std::string & Snapshot_GetFilename();
const std::string & Snapshot_GetPath();
void Snapshot_LoadState();
void Snapshot_SaveState();
void Snapshot_Startup();

View File

@ -968,10 +968,10 @@ void DDUninit(void)
static int g_nLastScreenShot = 0;
const int nMaxScreenShot = 999999999;
static TCHAR *g_pLastDiskImageName = NULL;
static std::string g_pLastDiskImageName;
//===========================================================================
void Video_ResetScreenshotCounter( TCHAR *pImageName )
void Video_ResetScreenshotCounter( const std::string & pImageName )
{
g_nLastScreenShot = 0;
g_pLastDiskImageName = pImageName;
@ -980,14 +980,14 @@ void Video_ResetScreenshotCounter( TCHAR *pImageName )
//===========================================================================
void Util_MakeScreenShotFileName( TCHAR *pFinalFileName_, DWORD chars )
{
const TCHAR * sPrefixScreenShotFileName = "AppleWin_ScreenShot";
const std::string sPrefixScreenShotFileName = "AppleWin_ScreenShot";
// TODO: g_sScreenshotDir
const TCHAR *pPrefixFileName = g_pLastDiskImageName ? g_pLastDiskImageName : sPrefixScreenShotFileName;
const std::string pPrefixFileName = !g_pLastDiskImageName.empty() ? g_pLastDiskImageName : sPrefixScreenShotFileName;
#if SCREENSHOT_BMP
StringCbPrintf( pFinalFileName_, chars, TEXT("%s_%09d.bmp"), pPrefixFileName, g_nLastScreenShot );
StringCbPrintf( pFinalFileName_, chars, TEXT("%s_%09d.bmp"), pPrefixFileName.c_str(), g_nLastScreenShot );
#endif
#if SCREENSHOT_TGA
StringCbPrintf( pFinalFileName_, chars, TEXT("%s%09d.tga"), pPrefixFileName, g_nLastScreenShot );
StringCbPrintf( pFinalFileName_, chars, TEXT("%s%09d.tga"), pPrefixFileName.c_str(), g_nLastScreenShot );
#endif
}

View File

@ -205,7 +205,7 @@ void VideoLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT version);
extern bool g_bDisplayPrintScreenFileName;
extern bool g_bShowPrintScreenWarningDialog;
void Video_ResetScreenshotCounter( char *pDiskImageFileName );
void Video_ResetScreenshotCounter( const std::string & pDiskImageFileName );
enum VideoScreenShot_e
{
SCREENSHOT_560x384 = 0,