Skip to content

Commit

Permalink
replace readlink with std::filesystem
Browse files Browse the repository at this point in the history
Simpler.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb authored and piponazo committed Apr 25, 2022
1 parent 6438305 commit d59e143
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/futils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,7 @@ std::string getProcessPath() {
ret = path;
}
#elif defined(__unix__)
// http://stackoverflow.com/questions/606041/how-do-i-get-the-path-of-a-process-in-unix-linux
char path[500];
ssize_t l = readlink("/proc/self/exe", path, sizeof(path) - 1);
if (l > 0) {
path[l] = 0;
ret = path;
}
ret = std::filesystem::read_symlink("/proc/self/exe");
#endif

const size_t idxLastSeparator = ret.find_last_of(EXV_SEPARATOR_STR);
Expand Down

0 comments on commit d59e143

Please sign in to comment.