openmode is passed before std::streambuf , but there are no methods to extract it. The only way to find out if a file is open for write operations is to write and check for f.fail() or optionally f.bad() (equivalent to f.rdstate() & std::fstream::badbit ).
jweyrich
source share