On (08 Aug 97) Herbert Bushong wrote to All...
HB> Is there a way to identify the mode that an fstream was opened in?
HB> (binary vs. text -- borland 4.5)
None of which I'm aware, but fortunately, it shouldn't be terribly
difficult to add the capability yourself:
class my_stream : public fstream {
int mode_;
public:
my_stream() : mode_(0), fstream() {}
my_stream(ÿconstÿchar*ÿname, intÿmode) :
fstream(name, mode), mode_(0) {}
my_stream(ÿfiledescÿfdÿ) :
fstream(fd), mode_(0) {}
my_stream(ÿfiledescÿfd, char*ÿbuffer, intÿlengthÿ) :
fstream(fd, buffer, lengt) , mdoe_(0) {}
voidÿopen(ÿconstÿchar*ÿname, intÿmode) :
mode_(mode)
{
fstream::open(name, mode);
}
int mode() {
return mode_;
}
};
You may have to add a few more things to this; for example, I believe
Borland supports a third parameter that determines the sharing allowed
with the file, and you may want to support that as well. Likewise, you
might have to get a bit more sophisticated with things: it's possible
that one of the constants for opening is actually 0, in which case you
might want to do something like keep track of whether the stream is
open to determine what sort of thing to return from mode().
Later,
Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)
|