Boost logo

Boost Users :

Subject: Re: [Boost-users] filesystem: create_directory unexpected exception
From: Craig Henderson (cdm.henderson_at_[hidden])
Date: 2009-07-27 12:43:25


2009/7/27 ciju john <johnc_at_[hidden]>

> 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<char*>& ) {
> 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<char
*> as Path will be a boost::filesystem::path type.
If in doubt, catch (std::exception &e) and inspect the type of e in the
debugger.

Regards
-- Craig



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net