exceptions from boost::filesystem not catchable on os/x 10.6.8 boost-1.47.0
os/x 10.6.8
uname -a
Darwin apple1 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
boost 1.47.0
./bootstrap.sh --prefix=$HOME/boost
./b2 link=static --disable-filesystem2 install # I've tried without disabling filesystem2, same result
gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
test app compiled:
g++ -Wall -I $HOME/boost/include fs.cpp -L$HOME/boost/lib -lboost_filesystem -lboost_system
otool -L a.out
a.out:
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
source below. when I run it with a non-existent filename I expect to catch an exception, but instead nothing happens, i.e. I just return to the shell prompt. I tried defining a struct locally and throwing it and the catch works fine.
any ideas?
thx
dxc
------------------------------------------------------------
#include <iostream>
#include
On Sep 4, 2011, at 5:51 PM, david x callaway
source below. when I run it with a non-existent filename I expect to catch an exception, but instead nothing happens, i.e. I just return to the shell prompt. I tried defining a struct locally and throwing it and the catch works fine.
any ideas?
Looks like it'll just return false unless something really bad happens. Cheers Gordon
-----Original Message-----
any ideas?
According to the documentation boost::filesystem::exists returns a bool to indicate if the path exists, an exception is thrown if something ... exceptional ... happens. ;-)
From the documentation:
bool exists(const path& p); bool exists(const path& p, system::error_code& ec); Returns: exists(status(p)) or exists(status(p, ec)), respectively. Throws: filesystem_error; overload with error_code& throws nothing. -- Best regards, Martin Dyring-Andersen
according to http://www.boost.org/doc/libs/1_47_0/libs/filesystem/v3/doc/reference.html#E... (search for "exists"): bool exists(const path& p); bool exists(const path& p, system::error_code& ec); Returns: exists(status(p)) or exists(status(p, ec)), respectively. Throws: filesystem_error; overload with error_code& throws nothing. I guess this hinges on what you think of as an error then, and you could argue that a file not existing *isn't* an error, it's just a condition. thx dxc On Sep 5, 2011, at 4:36 AM, Martin Dyring-Andersen wrote:
-----Original Message-----
any ideas?
According to the documentation boost::filesystem::exists returns a bool to indicate if the path exists, an exception is thrown if something ... exceptional ... happens. ;-)
From the documentation:
bool exists(const path& p); bool exists(const path& p, system::error_code& ec); Returns: exists(status(p)) or exists(status(p, ec)), respectively.
Throws: filesystem_error; overload with error_code& throws nothing.
-- Best regards, Martin Dyring-Andersen _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
david x callaway
-
Gordon Woodhull
-
Martin Dyring-Andersen