Boost C++ Libraries: Ticket #6932: create_directories throws exception even if error_code is specified https://svn.boost.org/trac10/ticket/6932 <p> code </p> <pre class="wiki"> boost::system::error_code errorCode; fs::create_directories(backupDirectory, errorCode); </pre><p> error </p> <pre class="wiki">Unhandled exception at 0x75c5b9bc in UsbPhoneWD.exe: Microsoft C++ exception: boost::filesystem3::filesystem_error at memory location 0x0257b6d0.. </pre><p> backtrace </p> <pre class="wiki">&gt; a.exe!`anonymous namespace'::process_status_failure(const boost::filesystem3::path &amp; p, boost::system::error_code * ec) Line 623 + 0x4b bytes C++ a.exe!boost::filesystem3::detail::status(const boost::filesystem3::path &amp; p, boost::system::error_code * ec) Line 1627 + 0x11 bytes C++ a.exe!boost::filesystem3::exists(const boost::filesystem3::path &amp; p) Line 289 + 0x30 bytes C++ a.exe!boost::filesystem3::detail::create_directories(const boost::filesystem3::path &amp; p, boost::system::error_code * ec) Line 927 + 0x18 bytes C++ a.exe!boost::filesystem3::create_directories(const boost::filesystem3::path &amp; p, boost::system::error_code &amp; ec) Line 403 + 0x2b bytes C++ </pre><p> boost::filesystem3::detail::create_directories Line 927 </p> <pre class="wiki"> BOOST_FILESYSTEM_DECL bool create_directories(const path&amp; p, system::error_code* ec) { if (p.empty() || exists(p)) &lt;- this is Line 927 { if (!p.empty() &amp;&amp; !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-&gt;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; } </pre><p> maybe "error_code dummy" should be pass to exists() and is_directory() to avoid throwing exception, just like create_directory do </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6932 Trac 1.4.3 xuefer@… Wed, 23 May 2012 04:20:57 GMT <link>https://svn.boost.org/trac10/ticket/6932#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6932#comment:1</guid> <description> <p> btw, it is reproduced when backupDirectory is a directory that has empty permission, every single permission is removed from the directory. (NTFS) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Mon, 28 May 2012 15:48:02 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6932#comment:2 https://svn.boost.org/trac10/ticket/6932#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78721" title="Filesystem: fix #6932, create_directories throws exception even if ...">[78721]</a>) Filesystem: fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6932" title="#6932: Bugs: create_directories throws exception even if error_code is specified (closed: fixed)">#6932</a>, create_directories throws exception even if error_code is specified. </p> Ticket xuefer@… Mon, 28 May 2012 16:05:32 GMT <link>https://svn.boost.org/trac10/ticket/6932#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6932#comment:3</guid> <description> <p> before i make some time to test it, i doubt this patch, are you sure it is fixed and the test passes? </p> <p> the exception is thrown by exists() call because no error_code is pass to it (check the call stack (the backtrace) i post). </p> <p> in <a class="changeset" href="https://svn.boost.org/trac10/changeset/78721" title="Filesystem: fix #6932, create_directories throws exception even if ...">[78721]</a>, create_directories still call exists(p) not error_code dummy; exists(p, dummy) like create_directory do currently. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Tue, 29 May 2012 15:55:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6932#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6932#comment:4</guid> <description> <p> See 78747. </p> <p> --Beman </p> </description> <category>Ticket</category> </item> </channel> </rss>