diff --git a/src/gl/imgui_hud.cpp b/src/gl/imgui_hud.cpp index a01f870c..37042a39 100644 --- a/src/gl/imgui_hud.cpp +++ b/src/gl/imgui_hud.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "font_default.h" #include "cpu.h" @@ -21,6 +22,8 @@ #include +namespace fs = ghc::filesystem; + namespace MangoHud { namespace GL { struct GLVec @@ -82,15 +85,9 @@ void imgui_init() if (sw_stats.engine != EngineTypes::ZINK){ sw_stats.engine = OPENGL; - stringstream ss; - string line; - auto pid = getpid(); - string path = "/proc/" + to_string(pid) + "/map_files/"; - auto files = exec("ls " + path); - ss << files; - - while(std::getline(ss, line, '\n')){ - auto file = path + line; + fs::path path("/proc/self/map_files/"); + for (auto& p : fs::directory_iterator(path)) { + auto file = p.path().string(); auto sym = read_symlink(file.c_str()); if (sym.find("wined3d") != std::string::npos) { sw_stats.engine = WINED3D; diff --git a/src/overlay.cpp b/src/overlay.cpp index 9e214f98..937c42b0 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "overlay.h" #include "logging.h" #include "cpu.h" @@ -27,6 +28,8 @@ #include #endif +namespace fs = ghc::filesystem; + #ifdef HAVE_DBUS float g_overflow = 50.f /* 3333ms * 0.5 / 16.6667 / 2 (to edge and back) */; #endif @@ -738,15 +741,10 @@ void init_system_info(){ wineVersion = ""; } // check for gamemode and vkbasalt - stringstream ss; - string line; - auto pid = getpid(); - string path = "/proc/" + to_string(pid) + "/map_files/"; - auto files = exec("ls " + path); - ss << files; - while(std::getline(ss, line, '\n')){ - auto file = path + line; - auto sym = read_symlink(file.c_str()); + fs::path path("/proc/self/map_files/"); + for (auto& p : fs::directory_iterator(path)) { + auto filename = p.path().string(); + auto sym = read_symlink(filename.c_str()); if (sym.find("gamemode") != std::string::npos) HUDElements.gamemode_bol = true; if (sym.find("vkbasalt") != std::string::npos)