Boost logo

Boost Users :

Subject: [Boost-users] Portable file I/O with system error codes support
From: Oleg Andriyanov (o.andriyanov_at_[hidden])
Date: 2017-08-23 16:07:50


Hi,

I'm looking for a portable way to open a file, read some data from it,
and do a proper error reporting in case of error.

Apparently std::fstream is not suitable for this task because it does
not provide means to retrieve original error code or even some human
readable description of what went wrong (checking errno does not count
since the standard does not guarantee it is set by any functions in
std::fstream).

I'm wondering if boost::iostreams can do that, but I've found nothing
this far that could help in getting the error code. I've also tried
boost::filesystem::fstream, but no luck.

Users of large frameworks like Qt have advantage of their portable
wrappers for file I/O like QFile. Are there any means in Boost which
provide similar functionality?

Related StackOverflow question:
https://stackoverflow.com/questions/45840686/portable-way-to-read-a-file-in-c-and-handle-possible-errors

Thanks.


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