Subject: [Boost-bugs] [Boost C++ Libraries] #6932: create_directories throws exception even if error_code is specified
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-23 04:12:43
#6932: create_directories throws exception even if error_code is specified
------------------------------+---------------------------------------------
Reporter: xuefer@⦠| Owner: bemandawes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
Version: Boost 1.49.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
code
{{{
boost::system::error_code errorCode;
fs::create_directories(backupDirectory, errorCode);
}}}
error
{{{
Unhandled exception at 0x75c5b9bc in UsbPhoneWD.exe: Microsoft C++
exception: boost::filesystem3::filesystem_error at memory location
0x0257b6d0..
}}}
backtrace
{{{
> a.exe!`anonymous namespace'::process_status_failure(const
boost::filesystem3::path & p, boost::system::error_code * ec) Line 623 +
0x4b bytes C++
a.exe!boost::filesystem3::detail::status(const
boost::filesystem3::path & p, boost::system::error_code * ec) Line 1627 +
0x11 bytes C++
a.exe!boost::filesystem3::exists(const boost::filesystem3::path &
p) Line 289 + 0x30 bytes C++
a.exe!boost::filesystem3::detail::create_directories(const
boost::filesystem3::path & p, boost::system::error_code * ec) Line 927 +
0x18 bytes C++
a.exe!boost::filesystem3::create_directories(const
boost::filesystem3::path & p, boost::system::error_code & ec) Line 403 +
0x2b bytes C++
}}}
boost::filesystem3::detail::create_directories Line 927
{{{
BOOST_FILESYSTEM_DECL
bool create_directories(const path& p, system::error_code* ec)
{
if (p.empty() || exists(p)) <- this is Line 927
{
if (!p.empty() && !is_directory(p))
{
if (ec == 0)
BOOST_FILESYSTEM_THROW(filesystem_error(
"boost::filesystem::create_directories", p,
error_code(system::errc::file_exists,
system::generic_category())));
else ec->assign(system::errc::file_exists,
system::generic_category());
}
return false;
}
// First create branch, by calling ourself recursively
create_directories(p.parent_path(), ec);
// Now that parent's path exists, create the directory
create_directory(p, ec);
return true;
}
}}}
maybe "error_code dummy" should be pass to exists() and is_directory() to
avoid throwing exception, just like create_directory do
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6932> 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-02-16 18:50:09 UTC