Make path separator OS-dependent (PR #954)

This commit is contained in:
Andrea
2021-05-19 21:10:22 +01:00
committed by GitHub
parent 1b9a769332
commit de7f35e6bd
10 changed files with 30 additions and 24 deletions
+3 -3
View File
@@ -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);