fix linux build

This commit is contained in:
Anthony 2024-03-10 22:34:34 +01:00
parent 37d79c5e33
commit 86337466c8
2 changed files with 19 additions and 1 deletions

View file

@ -9,7 +9,7 @@ jobs:
build_win:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install packages

View file

@ -202,6 +202,12 @@ std::string getExecutablePath()
#include <sstream>
// Typically Linux. For easy reading the comments will just say Linux but should work with most *nixes
#include <libgen.h> // dirname
#include <unistd.h> // readlink
#include <linux/limits.h> // PATH_MAX
static void throwOnRelative(const char *envName, const char *envValue)
{
if (envValue[0] != '/')
@ -265,6 +271,18 @@ namespace pf
}
#endif
std::string getExecutablePath()
{
char result[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", result, PATH_MAX);
const char *path;
if (count != -1) {
path = dirname(result);
}
return path;
}
std::string getDataHome()
{
#ifdef _WIN32