Skip to content
Snippets Groups Projects
Commit 672e3d96 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

pp

parent a0a51c8b
Branches
Tags
No related merge requests found
...@@ -389,27 +389,21 @@ std::string GetExecutableName(const std::string &argv0) ...@@ -389,27 +389,21 @@ std::string GetExecutableName(const std::string &argv0)
#elif defined(__APPLE__) #elif defined(__APPLE__)
char path[PATH_MAX]; char path[PATH_MAX];
uint32_t size = sizeof(path); uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size) == 0){ if(_NSGetExecutablePath(path, &size) == 0){
char real[PATH_MAX]; char real[PATH_MAX];
if(realpath(path, real)){ if(realpath(path, real)){
name = std::string(real); name = std::string(real);
} }
} }
#elif defined(__linux__) #elif defined(__linux__)
char path[PATH_MAX]; char path[4096];
int s = readlink("/proc/self/exe", path, sizeof(path)); if(readlink("/proc/self/exe", path, 4096) > 0){
if(s > 0){
path[s - 1] = '\0';
name = std::string(path); name = std::string(path);
} }
#endif #endif
if(name.empty()){ if(name.empty()){
name = argv0; name = argv0;
printf("Found executable name through argv0 = '%s'\n", name.c_str());
} }
else
printf("Found executable name = '%s'\n", name.c_str());
return name; return name;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment