Don't throw exceptions in file operations just to ignore them.

It doesn't make much sense to throw exceptions from `boost::filesystem` functions only to
immediately ignore them when we can call them with `boost::system::error_code` argument
to prevent the exceptions from being thrown in the first place.

Notice that while I'm not sure if ignoring all these exceptions is necessarily the right thing to
do it in the first place, I tried to avoid any changes in the code behaviour in this patch, so
I didn't do anything about this.
Nit-pic: All if/for/while statements must include curly braces:
if (ec) {
    return false;
}