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.
We can't use the ternary operator everywhere, so I thought using an `if` was better for consistency. But it doesn't matter, of course, I can change this if you really prefer the shorter version. Should I?