|
2 | 2 | #include "commands/cortex_upd_cmd.h" |
3 | 3 | #include "utils/cortex_utils.h" |
4 | 4 | #include "utils/file_manager_utils.h" |
| 5 | +#include "utils/widechar_conv.h" |
5 | 6 |
|
6 | 7 | namespace commands { |
7 | 8 |
|
@@ -57,24 +58,32 @@ bool ServerStartCmd::Exec(const std::string& host, int port, |
57 | 58 | ZeroMemory(&si, sizeof(si)); |
58 | 59 | si.cb = sizeof(si); |
59 | 60 | ZeroMemory(&pi, sizeof(pi)); |
60 | | - std::string params = "--start-server"; |
61 | | - params += " --config_file_path " + get_config_file_path(); |
62 | | - params += " --data_folder_path " + get_data_folder_path(); |
63 | | - params += " --loglevel " + log_level_; |
64 | | - std::string cmds = cortex_utils::GetCurrentPath() + "/" + exe + " " + params; |
| 61 | + std::wstring params = L"--start-server"; |
| 62 | + params += L" --config_file_path " + |
| 63 | + file_manager_utils::GetConfigurationPath().wstring(); |
| 64 | + params += L" --data_folder_path " + |
| 65 | + file_manager_utils::GetCortexDataPath().wstring(); |
| 66 | + params += L" --loglevel " + cortex::wc::Utf8ToWstring(log_level_); |
| 67 | + std::wstring exe_w = cortex::wc::Utf8ToWstring(exe); |
| 68 | + std::wstring current_path_w = |
| 69 | + file_manager_utils::GetExecutableFolderContainerPath().wstring(); |
| 70 | + std::wstring wcmds = current_path_w + L"/" + exe_w + L" " + params; |
| 71 | + CTL_DBG("wcmds: " << wcmds); |
| 72 | + std::vector<wchar_t> mutable_cmds(wcmds.begin(), wcmds.end()); |
| 73 | + mutable_cmds.push_back(L'\0'); |
65 | 74 | // Create child process |
66 | 75 | if (!CreateProcess( |
67 | 76 | NULL, // No module name (use command line) |
68 | | - const_cast<char*>( |
69 | | - cmds.c_str()), // Command line (replace with your actual executable) |
70 | | - NULL, // Process handle not inheritable |
71 | | - NULL, // Thread handle not inheritable |
72 | | - FALSE, // Set handle inheritance to FALSE |
73 | | - 0, // No creation flags |
74 | | - NULL, // Use parent's environment block |
75 | | - NULL, // Use parent's starting directory |
76 | | - &si, // Pointer to STARTUPINFO structure |
77 | | - &pi)) // Pointer to PROCESS_INFORMATION structure |
| 77 | + mutable_cmds |
| 78 | + .data(), // Command line (replace with your actual executable) |
| 79 | + NULL, // Process handle not inheritable |
| 80 | + NULL, // Thread handle not inheritable |
| 81 | + FALSE, // Set handle inheritance |
| 82 | + 0, // No creation flags |
| 83 | + NULL, // Use parent's environment block |
| 84 | + NULL, // Use parent's starting directory |
| 85 | + &si, // Pointer to STARTUPINFO structure |
| 86 | + &pi)) // Pointer to PROCESS_INFORMATION structure |
78 | 87 | { |
79 | 88 | std::cout << "Could not start server: " << GetLastError() << std::endl; |
80 | 89 | return false; |
@@ -115,7 +124,8 @@ bool ServerStartCmd::Exec(const std::string& host, int port, |
115 | 124 | std::string p = cortex_utils::GetCurrentPath() + "/" + exe; |
116 | 125 | execl(p.c_str(), exe.c_str(), "--start-server", "--config_file_path", |
117 | 126 | get_config_file_path().c_str(), "--data_folder_path", |
118 | | - get_data_folder_path().c_str(), "--loglevel", log_level_.c_str(), (char*)0); |
| 127 | + get_data_folder_path().c_str(), "--loglevel", log_level_.c_str(), |
| 128 | + (char*)0); |
119 | 129 | } else { |
120 | 130 | // Parent process |
121 | 131 | if (!TryConnectToServer(host, port)) { |
|
0 commit comments