Boost logo

Boost Users :

Subject: [Boost-users] Compiling probs with Filesystem in 1.38.0
From: Loreene Dixon (ldixon.dev_at_[hidden])
Date: 2009-03-11 19:07:00


 I successfully used Boost 1.33.1 with VS 2005.

Now I have the task of upgrading our software to VS 2008 ASAP and in so
doing, I upgraded our Boost to 1.38.0.

Apparently, Boost's Filesystem got revamped in 1.34.0 and the contents of
exception.hpp got moved to path.hpp and into Interprocess (!) library's
errors.hpp. We cannot call the error() routine anymore as it's no longer a
member of filesystem_error.

Here is an extract of our code (for Boost 1.33.1):

--------------------------------------------------
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/operations.hpp>
.
.
.
  vit::ViToolkitException&
  createViToolkitException(boost::filesystem::filesystem_error& e)
  {
     switch (e.error()) {
     case boost::filesystem::other_error:
     case boost::filesystem::path_error:
     case boost::filesystem::not_found_error:
     case boost::filesystem::not_directory_error:
     case boost::filesystem::already_exists_error:
        throw vit::BadPathException(e.what());

     default:
        throw vit::GeneralException(e.what());
     }
  }

  boost::filesystem::path createPath(const std::wstring& pathName)
  {
     try {
        return boost::filesystem::path(vit::wideStringToString(pathName),
                                                   boost::filesystem::native);
     }
     catch (boost::filesystem::filesystem_error& e) {
         throw createViToolkitException(e);
     }
   }
--------------------------------------------------

So basically we call Boost's methods and if an error occurs, we catch it and
throw createViToolkitException where it examines the error to determine
whether it's a bad path or general exception and throws a new appropriate
error.

When I attempted to compile Boost 1.38.0, my compiler errors were:

File.cc
File.cc(28) : error C2039: 'error' : is not a member of
'boost::filesystem::basic_filesystem_error<Path>'
with
[
Path=boost::filesystem::path
]
File.cc(29) : error C2039: 'other_error' : is not a member of
'boost::filesystem'
File.cc(29) : error C2065: 'other_error' : undeclared identifier
File.cc(29) : error C2051: case expression not constant
File.cc(30) : error C2039: 'path_error' : is not a member of
'boost::filesystem'
File.cc(30) : error C2065: 'path_error' : undeclared identifier
.
.
.

I changed the #include <boost/filesystem/exception.hpp> to #include
<boost/filesystem/path.hpp>.

I could change all 'boost::filesystem::filesystem_error' references to
'boost::filesystem::basic_filesystem_error'.

What can I do about the ' switch (e.error()) {' call since the error() call
is no longer available? Is there a different method that I should call?

And do I replace 'boost::filesystem::path_error' with
'boost::interprocess::path_error'?

What do I need to do in order to recompile in Boost 1.38.0 and still have
the same functionality? I inherited this code from our east coast developers
and am somewhat a Boost newbie.

Thanks!,
Loreene



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