From d78258d30732125e97a7b06534c7e901ff0f8bc7 Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Mon, 5 Aug 2024 00:13:35 -0400 Subject: [PATCH] V2024.8.1 --- CHANGELOG.md | 9 +++++++++ CMakeLists.txt | 2 +- Doxyfile | 2 +- manual/README.md | 7 ++----- src/system/environment.cpp | 5 +++-- src/system/process.cpp | 20 ++++++++------------ 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de2e2df..c38bfd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 2024.8.1 +### Breaking Changes +None +### New APIs +None +### Fixes +#### System +- Improved `Nickvision::System::Process`'s handling of arguments + ## 2024.8.0 ### Breaking Changes #### System diff --git a/CMakeLists.txt b/CMakeLists.txt index c6cf67c..28c9f88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") #libnick Definition -project ("libnick" LANGUAGES C CXX VERSION 2024.8.0 DESCRIPTION "A cross-platform base for native Nickvision applications.") +project ("libnick" LANGUAGES C CXX VERSION 2024.8.1 DESCRIPTION "A cross-platform base for native Nickvision applications.") include(CMakePackageConfigHelpers) include(GNUInstallDirs) include(CTest) diff --git a/Doxyfile b/Doxyfile index c48d240..e372072 100644 --- a/Doxyfile +++ b/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = "libnick" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "2024.8.0" +PROJECT_NUMBER = "2024.8.1" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/manual/README.md b/manual/README.md index 2aafd12..21ae326 100644 --- a/manual/README.md +++ b/manual/README.md @@ -6,15 +6,12 @@ libnick provides Nickvision apps with a common set of cross-platform APIs for managing system and desktop app functionality such as network management, taskbar icons, translations, app updates, and more. -## 2024.8.0 +## 2024.8.1 ### Breaking Changes -#### System -- `Nickvision::System::Process::kill()` will now kill child processes spawned by the respective process +None ### New APIs None ### Fixes -#### Logging -- Cleaned up the message logged by `Nickvision::Logging::Logger:log()` #### System - Improved `Nickvision::System::Process`'s handling of arguments diff --git a/src/system/environment.cpp b/src/system/environment.cpp index 677a87b..34fbcbc 100644 --- a/src/system/environment.cpp +++ b/src/system/environment.cpp @@ -131,10 +131,11 @@ namespace Nickvision::System { return ""; } + std::vector args{ StringHelpers::splitArgs(command) }; #ifdef _WIN32 - Process process{ findDependency("cmd.exe"), { "/C", command } }; + args.insert(args.begin(), "/c"); + Process process{ findDependency("cmd.exe"), args }; #else - std::vector args{ StringHelpers::splitArgs(command) }; std::string cmd{ args[0] }; args.erase(args.begin()); Process process{ cmd, args }; diff --git a/src/system/process.cpp b/src/system/process.cpp index 6029f38..5f98b45 100644 --- a/src/system/process.cpp +++ b/src/system/process.cpp @@ -47,31 +47,27 @@ namespace Nickvision::System throw std::runtime_error("Failed to create pipe."); } //Create process arguments - std::string appArgs{ "" }; - for(size_t i = 0; i < m_args.size(); i++) + std::wstring appArgs{ L"\"" + m_path.wstring() + L"\"" }; + for(const std::string& arg : m_args) { - const std::string arg{ m_args[i] }; if(arg.find(' ') != std::string::npos && arg[0] != '\"') { - appArgs += "\"" + arg + "\""; + appArgs += L" \"" + StringHelpers::wstr(arg) + L"\""; } else { - appArgs += arg; - } - if(i != m_args.size() - 1) - { - appArgs += " "; + appArgs += L" " + StringHelpers::wstr(arg); } } - STARTUPINFOA si{ 0 }; - si.cb = sizeof(STARTUPINFOA); + std::wcout << appArgs << std::endl; + STARTUPINFOW si{ 0 }; + si.cb = sizeof(STARTUPINFOW); si.hStdError = m_write; si.hStdOutput = m_write; si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; //Create process - if(!CreateProcessA(m_path.string().c_str(), LPSTR(appArgs.c_str()), nullptr, nullptr, TRUE, CREATE_SUSPENDED | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, nullptr, nullptr, &si, &m_pi)) + if(!CreateProcessW(nullptr, appArgs.data(), nullptr, nullptr, TRUE, CREATE_SUSPENDED | CREATE_NEW_PROCESS_GROUP, nullptr, nullptr, &si, &m_pi)) { std::cerr << CodeHelpers::getLastSystemError() << std::endl; CloseHandle(m_read);