filesystem: create_directory unexpected exception
Platform: Windows XP Pro
Boost version: 1.38 1.39 (BoostPro binary release)
try {
boost::filesystem::create_directory ("C:\Program Files\hello123");
}
catch (const boost::filesystem::basic_filesystem_error
Hi, try to escape the "\" to "C:\\Program Files\\hello123" Best Regards, Ingo ciju john schrieb:
Platform: Windows XP Pro Boost version: 1.38 1.39 (BoostPro binary release)
try { boost::filesystem::create_directory ("C:\Program Files\hello123"); } catch (const boost::filesystem::basic_filesystem_error
& ) { std::cerr << "Directory creation failed" << std::endl; } The above code crashes if user doesn't have root permission. I assume some exception is being thrown as catch (...) catches whatevers being thrown. The documentation says "Throws: basic_filesystem_error<Path> if Effects fails for any reason other than because the directory already exists." The requested directory "C:\Program Files\hello123" doesn't exist, so I should have caught a boost::filesystem::basic_filesystem_error. Is this a known issue or am I the only one seeing this?
thanks, john _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
2009/7/27 ciju john
Platform: Windows XP Pro Boost version: 1.38 1.39 (BoostPro binary release)
try { boost::filesystem::create_directory ("C:\Program Files\hello123"); } catch (const boost::filesystem::basic_filesystem_error
& ) { std::cerr << "Directory creation failed" << std::endl; } The above code crashes if user doesn't have root permission. I assume some exception is being thrown as catch (...) catches whatevers being thrown. The documentation says "Throws: basic_filesystem_error<Path> if Effects fails for any reason other than because the directory already exists." The requested directory "C:\Program Files\hello123" doesn't exist, so I should have caught a boost::filesystem::basic_filesystem_error. Is this a known issue or am I the only one seeing this?
basic_filesystem_error<Path> is not the same as basic_filesystem_error
On Mon, Jul 27, 2009 at 11:43 AM, Craig
Henderson
2009/7/27 ciju john
Platform: Windows XP Pro Boost version: 1.38 1.39 (BoostPro binary release)
try { boost::filesystem::create_directory ("C:\Program Files\hello123"); } catch (const boost::filesystem::basic_filesystem_error
& ) { std::cerr << "Directory creation failed" << std::endl; } The above code crashes if user doesn't have root permission. I assume some exception is being thrown as catch (...) catches whatevers being thrown. The documentation says "Throws: basic_filesystem_error<Path> if Effects fails for any reason other than because the directory already exists." The requested directory "C:\Program Files\hello123" doesn't exist, so I should have caught a boost::filesystem::basic_filesystem_error. Is this a known issue or am I the only one seeing this?
basic_filesystem_error<Path> is not the same as basic_filesystem_error
as Path will be a boost::filesystem::path type.
Right. Changing to basic_filesystem_error<Path> worked. I see a lot of the examples just catch std::exception. thanks... Ciju
If in doubt, catch (std::exception &e) and inspect the type of e in the debugger. Regards -- Craig _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Ciju John, Object Computing, Inc. St. Louis, USA - http://www.ociweb.com
On Mon, Jul 27, 2009 at 7:39 AM, ciju john
Platform: Windows XP Pro Boost version: 1.38 1.39 (BoostPro binary release)
try { boost::filesystem::create_directory ("C:\Program Files\hello123"); } catch (const boost::filesystem::basic_filesystem_error
& ) { std::cerr << "Directory creation failed" << std::endl; } The above code crashes if user doesn't have root permission. I assume some exception is being thrown as catch (...) catches whatevers being thrown. The documentation says "Throws: basic_filesystem_error<Path> if Effects fails for any reason other than because the directory already exists." The requested directory "C:\Program Files\hello123" doesn't exist, so I should have caught a boost::filesystem::basic_filesystem_error. Is this a known issue or am I the only one seeing this?
If you want to know what exception in being thrown, you could try
std::cerr << boost::current_exception_diagnostic_information() in the
catch(...), after including
participants (4)
-
ciju john
-
Craig Henderson
-
Emil Dotchevski
-
Ingo Maindorfer