Use realpath() instead of readlink() for fetching full pathnames

This commit is contained in:
baldurk
2016-08-19 17:26:11 +02:00
parent 724fef7bb6
commit 14c17cf5a5
+4 -2
View File
@@ -24,8 +24,10 @@
#include <dlfcn.h> // for dladdr
#include <errno.h>
#include <limits.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -72,8 +74,8 @@ void CreateParentDirectory(const string &filename)
string GetFullPathname(const string &filename)
{
char path[512] = {0};
readlink(filename.c_str(), path, 511);
char path[PATH_MAX + 1] = {0};
realpath(filename.c_str(), path);
return string(path);
}