- fixes for Windows build
This commit is contained in:
parent
978079fd55
commit
fa053324fa
|
|
@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.15)
|
||||||
project (helper_lib)
|
project (helper_lib)
|
||||||
|
|
||||||
# Rely on C++ 11
|
# Rely on C++ 11
|
||||||
set (CMAKE_CXX_STANDARD 11)
|
set (CMAKE_CXX_STANDARD 20)
|
||||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
option (USE_NULL_UUID "When enabled linking to libuuid is avoided" OFF)
|
option (USE_NULL_UUID "When enabled linking to libuuid is avoided" OFF)
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ std::string OsProcess::execCommand(const std::string& cmd)
|
||||||
PROCESS_INFORMATION pi = { 0 };
|
PROCESS_INFORMATION pi = { 0 };
|
||||||
|
|
||||||
char* cmdline = (char*)_alloca(cmd.size()+1);
|
char* cmdline = (char*)_alloca(cmd.size()+1);
|
||||||
strcpy(cmdline, StringHelper::replace(cmd, "/", "\\").c_str());
|
strcpy(cmdline, strx::replace(cmd, "/", "\\").c_str());
|
||||||
|
|
||||||
BOOL fSuccess = CreateProcessA( nullptr, cmdline, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
|
BOOL fSuccess = CreateProcessA( nullptr, cmdline, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
|
||||||
if (! fSuccess)
|
if (! fSuccess)
|
||||||
|
|
@ -114,7 +114,7 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
|
||||||
memset(&pi, 0, sizeof pi);
|
memset(&pi, 0, sizeof pi);
|
||||||
|
|
||||||
char* cmdbuffer = (char*)_alloca(cmdline.size()+1);
|
char* cmdbuffer = (char*)_alloca(cmdline.size()+1);
|
||||||
strcpy(cmdbuffer, StringHelper::replace(cmdline, "/", "\\").c_str());
|
strcpy(cmdbuffer, strx::replace(cmdline, "/", "\\").c_str());
|
||||||
|
|
||||||
|
|
||||||
BOOL fSuccess = CreateProcessA( nullptr, cmdbuffer, nullptr, nullptr, TRUE,
|
BOOL fSuccess = CreateProcessA( nullptr, cmdbuffer, nullptr, nullptr, TRUE,
|
||||||
|
|
@ -160,14 +160,14 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
|
||||||
{
|
{
|
||||||
std::string line(buf, cr - buf -1);
|
std::string line(buf, cr - buf -1);
|
||||||
if (callback)
|
if (callback)
|
||||||
callback(StringHelper::trim(line));
|
callback(strx::trim(line));
|
||||||
memmove(buf, cr + 1, strlen(cr+1) + 1);
|
memmove(buf, cr + 1, strlen(cr+1) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //for
|
} //for
|
||||||
|
|
||||||
if (buf[0])
|
if (buf[0])
|
||||||
callback(StringHelper::trim(std::string(buf)));
|
callback(strx::trim(std::string(buf)));
|
||||||
|
|
||||||
char ctrlc = 3;
|
char ctrlc = 3;
|
||||||
//if (finish_flag)
|
//if (finish_flag)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
#include "HL_Time.h"
|
#include "HL_Time.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <chrono>
|
||||||
/* return current time in milliseconds */
|
/* return current time in milliseconds */
|
||||||
double now_ms(void) {
|
double now_ms(void)
|
||||||
|
{
|
||||||
|
#if defined(TARGET_WIN)
|
||||||
|
auto tp = std::chrono::steady_clock::now();
|
||||||
|
auto result = std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch()).count();
|
||||||
|
return result;
|
||||||
|
#else
|
||||||
struct timespec res;
|
struct timespec res;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &res);
|
clock_gettime(CLOCK_MONOTONIC, &res);
|
||||||
return 1000.0 * res.tv_sec + (double) res.tv_nsec / 1e6;
|
return 1000.0 * res.tv_sec + (double) res.tv_nsec / 1e6;
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 34425a748bcad9235b58f97da25577947c501844
|
Subproject commit 0a786d3a7a49057ba31bf82a91269819f713c985
|
||||||
Loading…
Reference in New Issue