Boost logo

Boost Users :

Subject: Re: [Boost-users] Portable file I/O with system error codes support
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-08-23 17:28:07


> 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.

Literally https://ned14.github.io/afio/index.html

It's the post Boost peer review design after a peer review here in
August 2015. It looks to have some legs as part of a future C++
standardised replacement i/o layer for iostreams, Intel just very kindly
made available to me their Optane storage devices so I can tune AFIO v2
for them. I am currently (re)porting AFIO to FreeBSD and libc++
specifically for the Optane trials.

> 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).

The original error code is preserved on all platforms. So, on Windows,
that's the NT kernel error code if a NT kernel function was used. You
can use the C++ 11 STL mechanism of error conditions to compare the
original error code against any std::errc::* generic error condition,
and apart from bugs some of which stem from Microsoft's incorrect
mapping, it should work.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

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