Boost C++ Libraries: Ticket #11138: filesystem::path::canonical() failed with junction points on Windows https://svn.boost.org/trac10/ticket/11138 <p> Hi, </p> <p> In my recent use of filesystem in Boost 1.57, the call of path::canonical() on Windows 7 returns an invalid path if part of the path in question is a junction point. </p> <p> This failure can be reproduced with the following code: </p> <div class="wiki-code"><div class="code"><pre> <span class="c1">// &quot;C:\Gehua&quot; is a junction point of &quot;D:\Gehua&quot;</span> <span class="n">fs</span><span class="o">::</span><span class="n">path</span> <span class="n">work</span><span class="p">(</span><span class="s">&quot;d:/Gehua/work&quot;</span><span class="p">);</span> <span class="n">fs</span><span class="o">::</span><span class="n">path</span> <span class="n">work_canonical</span><span class="p">(</span><span class="n">fs</span><span class="o">::</span><span class="n">canonical</span><span class="p">(</span><span class="n">work</span><span class="p">));</span> <span class="n">std</span><span class="o">::</span><span class="n">wstring</span> <span class="n">s</span> <span class="o">=</span> <span class="n">fs</span><span class="o">::</span><span class="n">canonical</span><span class="p">(</span><span class="n">work_canonical</span><span class="p">).</span><span class="n">native</span><span class="p">();</span> <span class="c1">// True path passes</span> <span class="n">assert</span><span class="p">(</span><span class="n">s</span> <span class="o">==</span> <span class="sa">L</span><span class="s">&quot;d:/Gehua</span><span class="se">\\</span><span class="s">work&quot;</span><span class="p">);</span> <span class="c1">// try the junction path </span> <span class="n">fs</span><span class="o">::</span><span class="n">path</span> <span class="n">work_junction</span><span class="p">(</span><span class="s">&quot;c:/Gehua/work&quot;</span><span class="p">);</span> <span class="c1">// this passes</span> <span class="n">assert</span><span class="p">(</span><span class="n">fs</span><span class="o">::</span><span class="n">exists</span><span class="p">(</span><span class="n">work_junction</span><span class="p">));</span> <span class="n">s</span> <span class="o">=</span> <span class="n">fs</span><span class="o">::</span><span class="n">canonical</span><span class="p">(</span><span class="n">work_junction</span><span class="p">).</span><span class="n">native</span><span class="p">();</span> <span class="c1">// this one fails!</span> <span class="c1">// s has value &quot;c:/Gehua\\Gehua\\work&quot;</span> <span class="n">assert</span><span class="p">(</span><span class="n">s</span> <span class="o">==</span> <span class="sa">L</span><span class="s">&quot;d:/Gehua</span><span class="se">\\</span><span class="s">work&quot;</span><span class="p">);</span> </pre></div></div><p> The call returned a value of "c:/Gehua\\Gehua\\work", which was wrong. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11138 Trac 1.4.3 anonymous Tue, 24 Mar 2015 14:56:43 GMT attachment set https://svn.boost.org/trac10/ticket/11138 https://svn.boost.org/trac10/ticket/11138 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">a.cxx</span> </li> </ul> Ticket anonymous Wed, 19 Jul 2017 18:28:41 GMT <link>https://svn.boost.org/trac10/ticket/11138#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11138#comment:1</guid> <description> <p> This is a duplicate of ticket 10900, which outlines the real bug in read_symlink (the wrong element of a union is being read so that first 2 characters of the junction path end up being stripped out, removing the "c:" in your case). </p> </description> <category>Ticket</category> </item> </channel> </rss>