fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it.
2000-06-23 Benjamin Kosnik <bkoz@purist.soma.redhat.com> * bits/fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it. (basic_filebuf::close): Use it. * bits/std_fstream.h (basic_filebuf): Remove default arguments for filebuf ctor. (basic_filebuf): Add _M_fileno_based data member. As reported by brent verner <brent@rcfile.org> * testsuite/27_io/filebuf_members.cc: New file. * testsuite/27_io/filebuf_members-1.tst: New file. From-SVN: r34673
This commit is contained in:
parent
ba5fbc87e3
commit
81ef147959
@ -1,5 +1,14 @@
|
|||||||
2000-06-23 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
|
2000-06-23 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
|
||||||
|
|
||||||
|
* bits/fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it.
|
||||||
|
(basic_filebuf::close): Use it.
|
||||||
|
* bits/std_fstream.h (basic_filebuf): Remove default arguments for
|
||||||
|
filebuf ctor.
|
||||||
|
(basic_filebuf): Add _M_fileno_based data member.
|
||||||
|
As reported by brent verner <brent@rcfile.org>
|
||||||
|
* testsuite/27_io/filebuf_members.cc: New file.
|
||||||
|
* testsuite/27_io/filebuf_members-1.tst: New file.
|
||||||
|
|
||||||
* bits/std_fstream.h: Formatting tweaks.
|
* bits/std_fstream.h: Formatting tweaks.
|
||||||
* testsuite/27_io/ofstream_members.cc: New file.
|
* testsuite/27_io/ofstream_members.cc: New file.
|
||||||
* testsuite/27_io/ofstream_members-1.tst: New file.
|
* testsuite/27_io/ofstream_members-1.tst: New file.
|
||||||
|
@ -55,19 +55,20 @@ namespace std
|
|||||||
template<typename _CharT, typename _Traits>
|
template<typename _CharT, typename _Traits>
|
||||||
basic_filebuf<_CharT, _Traits>::
|
basic_filebuf<_CharT, _Traits>::
|
||||||
basic_filebuf()
|
basic_filebuf()
|
||||||
: __streambuf_type(), _M_file(NULL), _M_last_overflowed(false),
|
: __streambuf_type(), _M_file(NULL), _M_state_cur(), _M_state_beg(),
|
||||||
_M_state_cur(), _M_state_beg()
|
_M_last_overflowed(false), _M_fileno_based(false)
|
||||||
{ _M_fcvt = &use_facet<__codecvt_type>(this->getloc()); }
|
{ _M_fcvt = &use_facet<__codecvt_type>(this->getloc()); }
|
||||||
|
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits>
|
template<typename _CharT, typename _Traits>
|
||||||
basic_filebuf<_CharT, _Traits>::
|
basic_filebuf<_CharT, _Traits>::
|
||||||
basic_filebuf(int __fd, const char* /*__name*/, ios_base::openmode __mode)
|
basic_filebuf(int __fd, const char* /*__name*/, ios_base::openmode __mode)
|
||||||
: __streambuf_type(), _M_last_overflowed(false),
|
: __streambuf_type(), _M_state_cur(), _M_state_beg(),
|
||||||
_M_state_cur(), _M_state_beg()
|
_M_last_overflowed(false)
|
||||||
{
|
{
|
||||||
_M_fcvt = &use_facet<__codecvt_type>(this->getloc());
|
_M_fcvt = &use_facet<__codecvt_type>(this->getloc());
|
||||||
_M_init_filebuf();
|
_M_init_filebuf();
|
||||||
|
_M_fileno_based = true;
|
||||||
_M_file->sys_open(__fd, __mode);
|
_M_file->sys_open(__fd, __mode);
|
||||||
if (this->is_open() && _M_buf_size)
|
if (this->is_open() && _M_buf_size)
|
||||||
{
|
{
|
||||||
@ -142,8 +143,14 @@ namespace std
|
|||||||
_M_really_overflow(traits_type::eof());
|
_M_really_overflow(traits_type::eof());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_M_file->close())
|
bool __testclosed;
|
||||||
|
if (_M_fileno_based)
|
||||||
|
__testclosed = _M_file->sys_close();
|
||||||
|
else
|
||||||
|
__testclosed = _M_file->close();
|
||||||
|
|
||||||
|
if (__testclosed)
|
||||||
{
|
{
|
||||||
_M_mode = ios_base::openmode(0);
|
_M_mode = ios_base::openmode(0);
|
||||||
if (_M_buf_size)
|
if (_M_buf_size)
|
||||||
|
@ -66,19 +66,19 @@ namespace std {
|
|||||||
private:
|
private:
|
||||||
// Data Members:
|
// Data Members:
|
||||||
__file_type* _M_file;
|
__file_type* _M_file;
|
||||||
bool _M_last_overflowed; // XXX Needed?
|
|
||||||
__state_type _M_state_cur;// Current state type for codecvt.
|
__state_type _M_state_cur;// Current state type for codecvt.
|
||||||
__state_type _M_state_beg;
|
__state_type _M_state_beg;
|
||||||
const __codecvt_type* _M_fcvt; // Cached value from use_facet.
|
const __codecvt_type* _M_fcvt; // Cached value from use_facet.
|
||||||
__mutext_type _M_lock;
|
__mutext_type _M_lock;
|
||||||
|
bool _M_last_overflowed; // XXX Needed?
|
||||||
|
bool _M_fileno_based; // Open/closed via filenos.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors/destructor:
|
// Constructors/destructor:
|
||||||
basic_filebuf();
|
basic_filebuf();
|
||||||
|
|
||||||
// Non-standard ctor:
|
// Non-standard ctor:
|
||||||
basic_filebuf(int __fd, const char* __name = "unknown",
|
basic_filebuf(int __fd, const char* __name, ios_base::openmode __mode);
|
||||||
ios_base::openmode __mode = ios_base::in | ios_base::out);
|
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
~basic_filebuf()
|
~basic_filebuf()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user