Boost logo

Boost Users :

From: Daniel James (daniel_james_at_[hidden])
Date: 2006-08-19 16:42:50


Eric Hill wrote:
> Does anyone have any suggestions on how I can fix/diagnose/troubleshoot
> this little problem?
>
> 11 std::cout << "Parsing folder " << folder_name << std::endl;
> (gdb) n
> Parsing folder testing
> 12 boost::filesystem::path folder(folder_name,
> boost::filesystem::native);
> (gdb) n
> 13 boost::filesystem::path message_to = folder / ".to";
> (gdb) n
>
> Program received signal SIGABRT, Aborted.
> 0x4040583b in raise () from /lib/tls/libc.so.6
> (gdb)
>
I tried putting this into a little program (on Ubuntu, so it's a pretty
similar setup) and got this:

Parsing folder /home/daniel/test
terminate called after throwing an instance of
'boost::filesystem::filesystem_error'
  what(): boost::filesystem::path: invalid name ".to" in path: ".to"
Aborted

Which seems a little clearer. The exception is thrown because ".to"
isn't a portable path, so the solution is to write:

    boost::filesystem::path message_to = folder /
        boost::filesystem::path(".to", boost::filesystem::native);

Which is pretty horrible so you might want to try setting a more lenient
default name checker. I think you can do something like:

    // Allow any file name.
    bool name_check(std::string const&) {
        return true;
    }

    int main() {
        boost::filesystem::path::default_name_check(name_check);

        // ...
    }

Life will be a lot easier with Boost 1.34 as the automatic name checking
will be removed - but when it's going to be released is something of a
mystery.

As for why you're getting a SIGABRT instead of a nice error message, my
uneducated guess is that either your build process is turning of the
error handling or you have an exception safety error somewhere. If it's
not the former then you'll probably want to look at the call stack at
the point of the error.

Daniel


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