logic: fix FilePath::makeCanonical for case when working directory is symlink on Windows (issue #733)

This was broken because on first iteration loop the path passed to is_symlink was not a real path, thus boost uses the working dir instead.
This commit is contained in:
mlangkabel
2019-10-18 13:05:30 +02:00
committed by Eberhard Graether
parent eb142cfb4e
commit 122b384d60
+9 -2
View File
@@ -158,7 +158,14 @@ FilePath& FilePath::makeCanonical()
#if defined(_WIN32)
boost::filesystem::path abs_p = boost::filesystem::absolute(getPath());
for (boost::filesystem::path::iterator it = abs_p.begin(); it != abs_p.end(); ++it)
boost::filesystem::path::iterator it = abs_p.begin();
// add first element before loop because this won't be recognized as absolute path yet
canonicalPath /= *it;
it++;
for (; it != abs_p.end(); ++it)
{
if (*it == "..")
{
@@ -172,7 +179,7 @@ FilePath& FilePath::makeCanonical()
{
canonicalPath /= *it;
if (boost::filesystem::is_symlink(canonicalPath))
if (boost::filesystem::is_symlink(boost::filesystem::symlink_status(canonicalPath)))
{
boost::filesystem::path symlink = boost::filesystem::read_symlink(canonicalPath);
if (!symlink.empty())