mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Correctly implement FindPluginPath for Linux
This commit is contained in:
parent
366ff85de3
commit
229a6bc788
|
@ -3,6 +3,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
#include <Platform.h>
|
#include <Platform.h>
|
||||||
#include "../PluginAPI.h"
|
#include "../PluginAPI.h"
|
||||||
#include "../RSP.h"
|
#include "../RSP.h"
|
||||||
|
@ -71,6 +72,32 @@ void PluginAPI::FindPluginPath(wchar_t * _strPath)
|
||||||
GetModuleFileNameW(nullptr, _strPath, PLUGIN_PATH_SIZE);
|
GetModuleFileNameW(nullptr, _strPath, PLUGIN_PATH_SIZE);
|
||||||
_cutLastPathSeparator(_strPath);
|
_cutLastPathSeparator(_strPath);
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
|
std::ifstream maps;
|
||||||
|
std::string line;
|
||||||
|
std::size_t loc;
|
||||||
|
maps.open("/proc/self/maps");
|
||||||
|
|
||||||
|
if (maps.is_open())
|
||||||
|
{
|
||||||
|
while (getline(maps, line))
|
||||||
|
{
|
||||||
|
loc = line.find('/');
|
||||||
|
if (loc == std::string::npos)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
line = line.substr(loc);
|
||||||
|
|
||||||
|
if (line.find("GLideN64") != std::string::npos)
|
||||||
|
{
|
||||||
|
_getWSPath(line.c_str(), _strPath);
|
||||||
|
maps.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maps.close();
|
||||||
|
}
|
||||||
|
|
||||||
char path[512];
|
char path[512];
|
||||||
int res = readlink("/proc/self/exe", path, 510);
|
int res = readlink("/proc/self/exe", path, 510);
|
||||||
if (res != -1) {
|
if (res != -1) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user