44#define RESOURCES " Resources"
55#define BINARIES " Resources/Binaries"
66
7+ #include < vector>
78#include < cstdlib>
89#include < string>
910#include < filesystem>
@@ -30,19 +31,28 @@ int main(int argc, const char** argv)
3031 << " Check your installation instruction." << std::endl;
3132 return -1 ;
3233 }
33-
34- std::string realExecutablePath (PROJECT_EXE_RELATIVE_PATH);
3534
36- // Replace the forward slash with the reverse slash
37- size_t pos = 0 ;
35+ std::stringstream ss (PROJECT_EXE_RELATIVE_PATH);
36+ std::string tmp = " " ;
37+ const char del = ' /' ;
38+ std::vector<std::string> vec;
39+ vec.reserve (3 );
3840
39- // Replace Cmake's path with '/' to '\\'
40- while ((pos = realExecutablePath.find (' /' ,pos)) != std::string::npos)
41- realExecutablePath.replace (pos++, 1 , " \\\\ " );
41+ // Split Cmake's path by / in PROJECT_EXE_RELATIVE_PATH
42+ while (getline (ss, tmp, del))
43+ vec.push_back (tmp);
44+
45+ // Concat all stirng parts with \ character and excluding the last
46+ std::string accum = vec.at (0 );
47+ for (int i = 1 ; i < vec.size () - 1 ; i++)
48+ accum += ' \\ ' + vec.at (i);
49+
50+ // Form command like `start /D "Resources\Binaries" LoadEditor.exe`
51+ std::string realExecutablePath = " start /D \" " + accum + " \" " + " " + vec.at (vec.size () - 1 );
4252
4353 // Add commands from argv. Skip first argument because it is just MainStarter.cpp .exe name
4454 for (int i = 1 ; i < argc; i++)
45- realExecutablePath += std::string ( " " ) + std::string (argv[i]);
55+ realExecutablePath += " " + std::string (argv[i]);
4656
4757 // Call the main executable
4858 return system (realExecutablePath.c_str ());
0 commit comments