This commit is contained in:
2025-11-26 22:31:09 +01:00
parent 5023b63a7e
commit 28f0fdb520
7 changed files with 111 additions and 20 deletions

View File

@@ -3,7 +3,7 @@
#include "utils/whereami.h"
#include <iostream>
#ifdef __linux
#if defined(__linux) || defined(TARGET_OS_OSX)
#include <unistd.h>
#endif
@@ -15,6 +15,7 @@ extern "C" {
#include "gtk-imports.h"
}
#include <list>
#include <filesystem>
std::string InfoOverMe::containingFolder()
{
@@ -24,15 +25,21 @@ std::string InfoOverMe::containingFolder()
wai_getExecutablePath(path, len, NULL);
path[len] = '\0';
std::string p(path);
std::cout << p << std::endl;
return p;
std::filesystem::path p(path);
if (std::filesystem::is_regular_file(p)) {
std::filesystem::path pp = p.parent_path();
std::cout << pp << std::endl;
return pp.string();
} else {
std::cout << p << std::endl;
return p.string();
}
}
std::string InfoOverMe::myHostname()
{
char buf[10240];
#ifdef __linux
#if defined(__linux) || defined(TARGET_OS_OSX)
int r = gethostname(buf, 10240);
#endif
#ifdef _WIN32
@@ -53,9 +60,13 @@ std::string InfoOverMe::myOsHostname()
#else
#ifdef _WIN32
os = "windows";
#else
#ifdef TARGET_OS_OSX
os = "osx";
#else
os = "unknown";
#endif
#endif
#endif
return os + "_" + myHostname();
}