Subject: Re: [Boost-bugs] [Boost C++ Libraries] #13028: boost::filesystem::canonical(const path& p, system::error_code& ec) throws exception
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-07-14 19:13:00
#13028: boost::filesystem::canonical(const path& p, system::error_code& ec) throws
exception
----------------------------------------------+-------------------------
Reporter: Zach Wasserman <zachwass2000@â¦> | Owner: Beman Dawes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
Version: Boost 1.65.0 | Severity: Problem
Resolution: | Keywords:
----------------------------------------------+-------------------------
Comment (by anonymous):
I just ran into the same issue in one of our internal applications. There
are actually 2 bugs causing the same problem. The first is that the
{{{canonical(const path& p, system::error_code& ec)}}} calls
{{{current_path()}}} without passing in the {{{error_code}}}. However,
when that is fixed, then same problem shows up again if you pass in a
relative path as {{{base}}} because {{{detail::canonical()}}} immediately
calls {{{absolute()}}}, which in turn calls {{{current_path()}}}.
It's easy to fix by simply calling the no except version of
{{{current_path()}}} in both places (although, since {{{absolute()}}}
doesn't take an {{{error_code}}}, it can get a bit wordy):
operations.hpp:
{{{
inline
path canonical(const path& p, system::error_code& ec)
{
path base = detail::current_path(&ec);
if (ec)
return path();
return detail::canonical(p, base, &ec);
}
}}}
operations.cpp
{{{
BOOST_FILESYSTEM_DECL
path canonical(const path& p, const path& base, system::error_code* ec)
{
path source(p);
if (!p.is_absolute()) {
path absBase(base);
if (!absBase.is_absolute()) {
path curr = current_path(ec);
if (ec && *ec)
return path();
absBase = absolute(base, curr);
}
source = absolute(p, absBase);
}
}}}
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13028#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-07-14 19:16:57 UTC