From f12a92348f1fb48333f39e50e3d43a7832499c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lais=20Frig=C3=A9rio?= <laaisfrigerio@gmail.com> Date: Fri, 7 Jul 2017 09:24:27 -0300 Subject: [PATCH] SCRUM#87 - Get distro info on Windows --- CMakeLists.txt | 10 +--------- src/agent/get_distro.cpp | 8 +++----- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f032ae1..6358e61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,12 +40,6 @@ add_subdirectory ( lib/cpr ) include_directories ( ${CPR_INCLUDE_DIRS} ) include_directories ( ${CURL_INCLUDE_DIRS} ) -# src : DtWinVer - Windows Version/Edition class -# TODO: Incluir a biblioteca dtwinver ou encontrar outra similar -#if ( WIN32 ) -# add_subdirectory ( lib/dtwinver ) -#endif () - # headers include_directories ( "include" ) @@ -63,9 +57,7 @@ target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${CPR_LIBRARIES add_dependencies ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} Boost) -if ( WIN32 ) - #target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} dtwinver ) -else () +if ( UNIX ) # libudev target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} udev ) endif () diff --git a/src/agent/get_distro.cpp b/src/agent/get_distro.cpp index ae25231..d66eae4 100644 --- a/src/agent/get_distro.cpp +++ b/src/agent/get_distro.cpp @@ -155,19 +155,17 @@ std::string get_distro_win() { try { cmd = exec("systeminfo"); } catch (std::string err) { - throw std::string("unknown distro"); + return err; } - const std::string key = "Nome do sistema operacional:"; + const std::string key = "Microsoft Windows"; std::size_t found; found = cmd.find(key); std::istringstream iss(cmd); while (std::getline(iss, line)) { found = line.find(key); if (found != std::string::npos) { - return line.substr(found+key.length()+1, - // remove key - line.length()-(found+key.length()+1)); + return line.substr(found); } } } else if (!IsWindowsXPSP1OrGreater()) { -- GitLab