From 2de5b22c0be7fb39eaa5bd5815777f1d049ebe1f Mon Sep 17 00:00:00 2001 From: Jelly Date: Thu, 16 Jul 2026 21:27:13 +0300 Subject: [PATCH 1/3] Fixing the potential flaw code in windows environment --- src/settings_manager.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/settings_manager.cpp b/src/settings_manager.cpp index 6425846..f9ded0f 100644 --- a/src/settings_manager.cpp +++ b/src/settings_manager.cpp @@ -22,6 +22,11 @@ #include #include + +#ifdef _WIN32 +#include +#endif + settings_manager::settings_manager() { load(); } @@ -49,9 +54,13 @@ void settings_manager::set_logo(logo_style style) { std::string settings_manager::get_config_dir() const { #ifdef _WIN32 // win32 default appdata - const char* appdata = std::getenv("APPDATA"); + char* appdata = new char[MAX_PATH]; // MAX_PATH from windows + GetEnvironmentVariableA("APPDATA", appdata, MAX_PATH); if (appdata) { - return std::string(appdata) + "/tpedia"; + std::string temp(appdata); + temp += "/tpedia"; + delete appdata; + return temp; } return "./tpedia_config"; #elif defined(__APPLE__) @@ -118,4 +127,4 @@ void settings_manager::save() { settings_manager::logo_style settings_manager::logo() { return lgo; -} \ No newline at end of file +} From 5f1f49d7d2b3a953ad759766d3acd17bb6f94550 Mon Sep 17 00:00:00 2001 From: Jelly Date: Thu, 16 Jul 2026 21:48:47 +0300 Subject: [PATCH 2/3] Added kernel32.lib for GetEnvironmentVariableA --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d31e2..dd14634 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,10 +86,13 @@ set(SOURCES add_executable(${PROJECT_NAME} ${SOURCES}) +set(windows_api "") + if(WIN32 AND MSVC) # Limit assets embeding to msvc compilers only # such as clang-cl and MSVC (there exists no compiler of msvc flags # in the market except these two. Clang-cl is peak tho) target_sources(${PROJECT_NAME} PRIVATE assets/resource.rc) + set(windows_api "kernel32.lib") endif() target_compile_definitions(${PROJECT_NAME} PRIVATE @@ -103,6 +106,7 @@ target_include_directories(${PROJECT_NAME} ) target_link_libraries(${PROJECT_NAME} PRIVATE + ${windows_api} nlohmann_json::nlohmann_json ftxui::ftxui OpenSSL::SSL From 634743fd2936b161d0b748b830a2aa40a8aa643f Mon Sep 17 00:00:00 2001 From: Cyphrixz Date: Fri, 17 Jul 2026 16:07:33 +0530 Subject: [PATCH 3/3] Refactor target_link_libraries for platform-specific linking --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd14634..57c7a00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,10 +105,19 @@ target_include_directories(${PROJECT_NAME} "${CMAKE_CURRENT_BINARY_DIR}/third_party" ) +if(WIN32) target_link_libraries(${PROJECT_NAME} PRIVATE - ${windows_api} + ${windows_api} nlohmann_json::nlohmann_json ftxui::ftxui OpenSSL::SSL OpenSSL::Crypto ) +else() +target_link_libraries(${PROJECT_NAME} PRIVATE + nlohmann_json::nlohmann_json + ftxui::ftxui + OpenSSL::SSL + OpenSSL::Crypto +) +endif()