mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Correctly implement FindPluginPath for Linux
This commit is contained in:
parent
366ff85de3
commit
229a6bc788
|
@ -3,6 +3,7 @@
|
|||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <Platform.h>
|
||||
#include "../PluginAPI.h"
|
||||
#include "../RSP.h"
|
||||
|
@ -71,6 +72,32 @@ void PluginAPI::FindPluginPath(wchar_t * _strPath)
|
|||
GetModuleFileNameW(nullptr, _strPath, PLUGIN_PATH_SIZE);
|
||||
_cutLastPathSeparator(_strPath);
|
||||
#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];
|
||||
int res = readlink("/proc/self/exe", path, 510);
|
||||
if (res != -1) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user