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 <memory>
#include <unistd.h>
#include <filesystem.h>
#include <imgui.h>
#include "font_default.h"
#include "cpu.h"
@ -21,6 +22,8 @@
#include <glad/glad.h>
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;

@ -4,6 +4,7 @@
#include <thread>
#include <condition_variable>
#include <spdlog/spdlog.h>
#include <filesystem.h>
#include "overlay.h"
#include "logging.h"
#include "cpu.h"
@ -27,6 +28,8 @@
#include <unistd.h>
#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)

Loading…
Cancel
Save