mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 05:10:26 +00:00
Use a Boost API to resolve symlinks instead of low-level code
This commit is contained in:
parent
03cdffb555
commit
5d94a94a98
1 changed files with 6 additions and 3 deletions
|
@ -80,14 +80,17 @@ boost::filesystem::path LinuxPath::getGlobalConfigPath() const
|
||||||
boost::filesystem::path LinuxPath::getLocalPath() const
|
boost::filesystem::path LinuxPath::getLocalPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path localPath("./");
|
boost::filesystem::path localPath("./");
|
||||||
std::string binPath(pathconf(".", _PC_PATH_MAX), '\0');
|
|
||||||
const char *statusPaths[] = {"/proc/self/exe", "/proc/self/file", "/proc/curproc/exe", "/proc/curproc/file"};
|
const char *statusPaths[] = {"/proc/self/exe", "/proc/self/file", "/proc/curproc/exe", "/proc/curproc/file"};
|
||||||
|
|
||||||
for(const char *path : statusPaths)
|
for(const char *path : statusPaths)
|
||||||
{
|
{
|
||||||
if (readlink(path, &binPath[0], binPath.size()) != -1)
|
boost::filesystem::path statusPath(path);
|
||||||
|
if (!boost::filesystem::exists(statusPath)) continue;
|
||||||
|
|
||||||
|
statusPath = boost::filesystem::read_symlink(statusPath);
|
||||||
|
if (!boost::filesystem::is_empty(statusPath))
|
||||||
{
|
{
|
||||||
localPath = boost::filesystem::path(binPath).parent_path() / "/";
|
localPath = statusPath.parent_path() / "/";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue