|
Boost : |
Subject: [boost] [filesystem][system] Usage guideline request
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-11-04 09:18:12
Hi,
I'm updating our software from Boost 1.33 to 1.40 and one of the major
issues I encountered is using exceptions from Boost.Filesystem. The
exception basic_filesystem_error has changed its interface in a breaking
way, as it now relies on Boost.System error codes. I'm not aware of
whether this change has been announced properly and the API deprecation
period has been offered. And that is actually not what bothers me mostly.
The 1.33 version of Boost.Filesystem offered a number of unified error
codes that our code used to react accordingly. For example, there were
error codes out_of_space_error, already_exists_error, which were used on
any platform supported by Boost.Filesystem. Now, with Boost.System in
place, there are at least three sets of errors: system::errc,
system::windows_error and system::linux_error, although, I assume, the
latter is an addition to system::errc. In order to check for the older
out_of_space_error I now have to write something like this:
catch (basic_filesystem_error& e)
{
if (
e.code() == system::errc::make_error_code(
system::errc::no_space_on_device)
#if defined(WIN32)
|| e.code() == system::windows_error::make_error_code(
system::windows_error::disk_full)
#endif
)
{
// out_of_space_error
}
}
Is this the right way to do this? Is there a portable way to do it?
I tried to find a better way in the Boost.System documentation, but was
highly disappointed as there is virtually no documentation at all. Also,
no examples available for this library. I wonder how this library passed
the review in the first place.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk