diff --git a/source/Common.h b/source/Common.h index 21c8b8af..e5ea19e7 100644 --- a/source/Common.h +++ b/source/Common.h @@ -143,6 +143,12 @@ enum AppMode_e #define WM_USER_FULLSCREEN WM_USER+8 #define VK_SNAPSHOT_TEXT WM_USER+9 // PrintScreen+Ctrl +#ifdef _MSC_VER +#define PATH_SEPARATOR '\\' +#else +#define PATH_SEPARATOR '/' +#endif + enum eIRQSRC {IS_6522=0, IS_SPEECH, IS_SSC, IS_MOUSE}; // diff --git a/source/Core.cpp b/source/Core.cpp index 4eba1bda..79dae7bd 100644 --- a/source/Core.cpp +++ b/source/Core.cpp @@ -288,8 +288,8 @@ bool SetCurrentImageDir(const std::string& pszImageDir) { g_sCurrentDir = pszImageDir; - if (!g_sCurrentDir.empty() && *g_sCurrentDir.rbegin() != '\\') - g_sCurrentDir += '\\'; + if (!g_sCurrentDir.empty() && *g_sCurrentDir.rbegin() != PATH_SEPARATOR) + g_sCurrentDir += PATH_SEPARATOR; if (SetCurrentDirectory(g_sCurrentDir.c_str())) return true; diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 5741ae24..25854672 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -3690,7 +3690,7 @@ Update_t CmdConfigSetDebugDir (int nArgs) { sPath = g_aArgs[1].sArg; } - else if (g_aArgs[1].sArg[0] == '\\') // Absolute + else if (g_aArgs[1].sArg[0] == PATH_SEPARATOR) // Absolute { if (g_sCurrentDir[1] == ':') { @@ -5982,7 +5982,7 @@ Update_t CmdOutputRun (int nArgs) sMiniFileName = pFileName.substr(0, MIN(pFileName.size(), CONSOLE_WIDTH)); // strcat( sMiniFileName, ".aws" ); // HACK: MAGIC STRING - if (pFileName[0] == '\\' || pFileName[1] == ':') // NB. Any prefix quote has already been stripped + if (pFileName[0] == PATH_SEPARATOR || pFileName[1] == ':') // NB. Any prefix quote has already been stripped { // Abs pathname sFileName = sMiniFileName; diff --git a/source/Disk.cpp b/source/Disk.cpp index df476444..21188e2a 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -202,7 +202,7 @@ void Disk2InterfaceCard::SaveLastDiskImage(const int drive) TCHAR szPathName[MAX_PATH]; StringCbCopy(szPathName, MAX_PATH, DiskGetFullPathName(drive).c_str()); - TCHAR* slash = _tcsrchr(szPathName, TEXT('\\')); + TCHAR* slash = _tcsrchr(szPathName, TEXT(PATH_SEPARATOR)); if (slash != NULL) { slash[1] = '\0'; @@ -599,7 +599,7 @@ void Disk2InterfaceCard::GetFilenameAndPathForSaveState(std::string& filename, s filename = GetBaseName(i); std::string pathname = DiskGetFullPathName(i); - int idx = pathname.find_last_of('\\'); + int idx = pathname.find_last_of(PATH_SEPARATOR); if (idx >= 0 && idx+1 < (int)pathname.length()) // path exists? { path = pathname.substr(0, idx+1); diff --git a/source/DiskImage.cpp b/source/DiskImage.cpp index 4ccc160c..1dc0e3d9 100644 --- a/source/DiskImage.cpp +++ b/source/DiskImage.cpp @@ -260,8 +260,8 @@ void GetImageTitle(LPCTSTR pPathname, std::string & pImageName, std::string & pF LPCTSTR startpos = pPathname; // imagetitle = - if (_tcsrchr(startpos, TEXT('\\'))) - startpos = _tcsrchr(startpos, TEXT('\\'))+1; + if (_tcsrchr(startpos, TEXT(PATH_SEPARATOR))) + startpos = _tcsrchr(startpos, TEXT(PATH_SEPARATOR))+1; _tcsncpy(imagetitle, startpos, MAX_DISK_FULL_NAME); imagetitle[MAX_DISK_FULL_NAME] = 0; diff --git a/source/DiskImageHelper.cpp b/source/DiskImageHelper.cpp index 8e2b48ce..c0d4a6d2 100644 --- a/source/DiskImageHelper.cpp +++ b/source/DiskImageHelper.cpp @@ -1541,8 +1541,8 @@ void CImageHelperBase::GetCharLowerExt(TCHAR* pszExt, LPCTSTR pszImageFilename, { LPCTSTR pImageFileExt = pszImageFilename; - if (_tcsrchr(pImageFileExt, TEXT('\\'))) - pImageFileExt = _tcsrchr(pImageFileExt, TEXT('\\'))+1; + if (_tcsrchr(pImageFileExt, TEXT(PATH_SEPARATOR))) + pImageFileExt = _tcsrchr(pImageFileExt, TEXT(PATH_SEPARATOR))+1; if (_tcsrchr(pImageFileExt, TEXT('.'))) pImageFileExt = _tcsrchr(pImageFileExt, TEXT('.')); diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 7a70b0ed..6b77f8a9 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -247,9 +247,9 @@ static void HD_SaveLastDiskImage(const int iDrive) char szPathName[MAX_PATH]; strcpy(szPathName, HD_GetFullPathName(iDrive).c_str()); - if (_tcsrchr(szPathName, TEXT('\\'))) + if (_tcsrchr(szPathName, TEXT(PATH_SEPARATOR))) { - char* pPathEnd = _tcsrchr(szPathName, TEXT('\\'))+1; + char* pPathEnd = _tcsrchr(szPathName, TEXT(PATH_SEPARATOR))+1; *pPathEnd = 0; RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, szPathName); } @@ -335,7 +335,7 @@ void HD_GetFilenameAndPathForSaveState(std::string& filename, std::string& path) filename = HD_DiskGetBaseName(i); std::string pathname = HD_GetFullPathName(i); - int idx = pathname.find_last_of('\\'); + int idx = pathname.find_last_of(PATH_SEPARATOR); if (idx >= 0 && idx+1 < (int)pathname.length()) // path exists? { path = pathname.substr(0, idx+1); diff --git a/source/SaveState.cpp b/source/SaveState.cpp index 396fb63e..caf58958 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -86,8 +86,8 @@ static void Snapshot_SetPathname(const std::string& strPathname) g_strSaveStateFilename = DEFAULT_SNAPSHOT_NAME; g_strSaveStatePathname = g_sCurrentDir; - if (!g_strSaveStatePathname.empty() && *g_strSaveStatePathname.rbegin() != '\\') - g_strSaveStatePathname += "\\"; + if (!g_strSaveStatePathname.empty() && *g_strSaveStatePathname.rbegin() != PATH_SEPARATOR) + g_strSaveStatePathname += PATH_SEPARATOR; g_strSaveStatePathname.append(DEFAULT_SNAPSHOT_NAME); g_strSaveStatePath = g_sCurrentDir; @@ -97,7 +97,7 @@ static void Snapshot_SetPathname(const std::string& strPathname) std::string strFilename = strPathname; // Set default, as maybe there's no path g_strSaveStatePath.clear(); - int nIdx = strPathname.find_last_of('\\'); + int nIdx = strPathname.find_last_of(PATH_SEPARATOR); if (nIdx >= 0 && nIdx+1 < (int)strPathname.length()) // path exists? { strFilename = &strPathname[nIdx+1]; @@ -113,12 +113,12 @@ void Snapshot_SetFilename(const std::string& filename, const std::string& path/* if (path.empty()) return Snapshot_SetPathname(filename); - _ASSERT(filename.find('\\') == std::string::npos); // since we have a path, then filename mustn't contain a path too! + _ASSERT(filename.find(PATH_SEPARATOR) == std::string::npos); // since we have a path, then filename mustn't contain a path too! // Ensure path is suffixed with '\' before adding filename std::string pathname = path; - if (*pathname.rbegin() != '\\') - pathname += "\\"; + if (*pathname.rbegin() != PATH_SEPARATOR) + pathname += PATH_SEPARATOR; Snapshot_SetPathname(pathname+filename); } diff --git a/source/Utilities.cpp b/source/Utilities.cpp index 2f2890d9..7be4f674 100644 --- a/source/Utilities.cpp +++ b/source/Utilities.cpp @@ -321,7 +321,7 @@ static std::string GetFullPath(LPCSTR szFileName) { std::string strPathName; - if (szFileName[0] == '\\' || szFileName[1] == ':') + if (szFileName[0] == PATH_SEPARATOR || szFileName[1] == ':') { // Abs pathname strPathName = szFileName; @@ -344,7 +344,7 @@ static void SetCurrentDir(std::string pathname) // . if -[sN]d1 and -[sN]d2 are specified, then g_sCurrentDir will be set to the d2 image's path // This is purely dependent on the current order of InsertFloppyDisks() & InsertHardDisks() - ie. very brittle! // . better to use -current-dir to be explicit - std::size_t found = pathname.find_last_of("\\"); + std::size_t found = pathname.find_last_of(PATH_SEPARATOR); std::string path = pathname.substr(0, found); SetCurrentImageDir(path); } diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index 46d036c5..dda970dc 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -340,7 +340,7 @@ static void GetProgramDirectory(void) int loop = g_sProgramDir.size(); while (loop--) { - if ((g_sProgramDir[loop] == TEXT('\\')) || (g_sProgramDir[loop] == TEXT(':'))) + if ((g_sProgramDir[loop] == TEXT(PATH_SEPARATOR)) || (g_sProgramDir[loop] == TEXT(':'))) { g_sProgramDir.resize(loop + 1); // this reduces the size break; @@ -619,7 +619,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) char startDir[_MAX_PATH]; GetCurrentDirectory(sizeof(startDir), startDir); g_sStartDir = startDir; - if (*(g_sStartDir.end()-1) != '\\') g_sStartDir += '\\'; + if (*(g_sStartDir.end()-1) != PATH_SEPARATOR) g_sStartDir += PATH_SEPARATOR; if (!ProcessCmdLine(lpCmdLine)) return 0; @@ -948,7 +948,7 @@ static void RepeatInitialization(void) if (g_cmdLine.szSnapshotName) { std::string strPathname(g_cmdLine.szSnapshotName); - int nIdx = strPathname.find_last_of('\\'); + int nIdx = strPathname.find_last_of(PATH_SEPARATOR); if (nIdx >= 0 && nIdx+1 < (int)strPathname.length()) // path exists? { const std::string strPath = strPathname.substr(0, nIdx+1);