Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build success on Ubuntu 20.10 #1

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/picotorrent/core/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <Windows.h>
#include <ShlObj.h>
#include <Shlwapi.h>
#elif __linux__
#include <unistd.h>
#else
#include <mach-o/dyld.h>
#endif
Expand Down Expand Up @@ -70,6 +72,14 @@ fs::path Environment::GetApplicationPath()
GetModuleFileName(NULL, path, ARRAYSIZE(path));
PathRemoveFileSpec(path);
return path;
#elif __linux__
const size_t bufSize = PATH_MAX + 1;
char buf[PATH_MAX];
char dirNameBuffer[bufSize];
const char *linkName = "/proc/self/exe";
const int ret = int(readlink(linkName, dirNameBuffer, bufSize - 1));
char* rp = realpath(dirNameBuffer, buf);
return fs::path(rp).parent_path();
#else
char path[1024];
uint32_t size = sizeof(path);
Expand Down