Use `ghc::filesystem` to iterate over /proc/self/map_files

pull/609/head
jackun 3 years ago
parent c452609718
commit 6584f23a6c
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -6,6 +6,7 @@
#include <sstream> #include <sstream>
#include <memory> #include <memory>
#include <unistd.h> #include <unistd.h>
#include <filesystem.h>
#include <imgui.h> #include <imgui.h>
#include "font_default.h" #include "font_default.h"
#include "cpu.h" #include "cpu.h"
@ -21,6 +22,8 @@
#include <glad/glad.h> #include <glad/glad.h>
namespace fs = ghc::filesystem;
namespace MangoHud { namespace GL { namespace MangoHud { namespace GL {
struct GLVec struct GLVec
@ -82,15 +85,9 @@ void imgui_init()
if (sw_stats.engine != EngineTypes::ZINK){ if (sw_stats.engine != EngineTypes::ZINK){
sw_stats.engine = OPENGL; sw_stats.engine = OPENGL;
stringstream ss; fs::path path("/proc/self/map_files/");
string line; for (auto& p : fs::directory_iterator(path)) {
auto pid = getpid(); auto file = p.path().string();
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()); auto sym = read_symlink(file.c_str());
if (sym.find("wined3d") != std::string::npos) { if (sym.find("wined3d") != std::string::npos) {
sw_stats.engine = WINED3D; sw_stats.engine = WINED3D;

@ -4,6 +4,7 @@
#include <thread> #include <thread>
#include <condition_variable> #include <condition_variable>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <filesystem.h>
#include "overlay.h" #include "overlay.h"
#include "logging.h" #include "logging.h"
#include "cpu.h" #include "cpu.h"
@ -27,6 +28,8 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
namespace fs = ghc::filesystem;
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
float g_overflow = 50.f /* 3333ms * 0.5 / 16.6667 / 2 (to edge and back) */; float g_overflow = 50.f /* 3333ms * 0.5 / 16.6667 / 2 (to edge and back) */;
#endif #endif
@ -738,15 +741,10 @@ void init_system_info(){
wineVersion = ""; wineVersion = "";
} }
// check for gamemode and vkbasalt // check for gamemode and vkbasalt
stringstream ss; fs::path path("/proc/self/map_files/");
string line; for (auto& p : fs::directory_iterator(path)) {
auto pid = getpid(); auto filename = p.path().string();
string path = "/proc/" + to_string(pid) + "/map_files/"; auto sym = read_symlink(filename.c_str());
auto files = exec("ls " + path);
ss << files;
while(std::getline(ss, line, '\n')){
auto file = path + line;
auto sym = read_symlink(file.c_str());
if (sym.find("gamemode") != std::string::npos) if (sym.find("gamemode") != std::string::npos)
HUDElements.gamemode_bol = true; HUDElements.gamemode_bol = true;
if (sym.find("vkbasalt") != std::string::npos) if (sym.find("vkbasalt") != std::string::npos)

Loading…
Cancel
Save