mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-29 08:30:04 +00:00
Make path separator OS-dependent (PR #954)
This commit is contained in:
parent
1b9a769332
commit
de7f35e6bd
@ -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};
|
||||
|
||||
//
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -260,8 +260,8 @@ void GetImageTitle(LPCTSTR pPathname, std::string & pImageName, std::string & pF
|
||||
LPCTSTR startpos = pPathname;
|
||||
|
||||
// imagetitle = <FILENAME.EXT>
|
||||
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;
|
||||
|
@ -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('.'));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user