mirror of
https://github.com/boostorg/nowide.git
synced 2026-02-22 03:22:32 +00:00
Call close on destruction of filebuf
Mandated by standard Remove superflous braces and dtor from fstreams
This commit is contained in:
@@ -64,11 +64,7 @@ namespace nowide {
|
||||
|
||||
virtual ~basic_filebuf()
|
||||
{
|
||||
if(file_)
|
||||
{
|
||||
::fclose(file_);
|
||||
file_ = 0;
|
||||
}
|
||||
close();
|
||||
if(own_ && buffer_)
|
||||
delete[] buffer_;
|
||||
}
|
||||
|
||||
@@ -68,12 +68,9 @@ namespace nowide {
|
||||
void open(char const *file_name, std::ios_base::openmode mode = std::ios_base::in)
|
||||
{
|
||||
if(!buf_.open(file_name, mode | std::ios_base::in))
|
||||
{
|
||||
this->setstate(std::ios_base::failbit);
|
||||
} else
|
||||
{
|
||||
else
|
||||
this->clear();
|
||||
}
|
||||
}
|
||||
bool is_open()
|
||||
{
|
||||
@@ -87,18 +84,12 @@ namespace nowide {
|
||||
{
|
||||
if(!buf_.close())
|
||||
this->setstate(std::ios_base::failbit);
|
||||
else
|
||||
this->clear();
|
||||
}
|
||||
|
||||
internal_buffer_type *rdbuf() const
|
||||
{
|
||||
return const_cast<internal_buffer_type *>(&buf_);
|
||||
}
|
||||
~basic_ifstream()
|
||||
{
|
||||
buf_.close();
|
||||
}
|
||||
|
||||
private:
|
||||
internal_buffer_type buf_;
|
||||
@@ -137,12 +128,9 @@ namespace nowide {
|
||||
void open(char const *file_name, std::ios_base::openmode mode = std::ios_base::out)
|
||||
{
|
||||
if(!buf_.open(file_name, mode | std::ios_base::out))
|
||||
{
|
||||
this->setstate(std::ios_base::failbit);
|
||||
} else
|
||||
{
|
||||
else
|
||||
this->clear();
|
||||
}
|
||||
}
|
||||
bool is_open()
|
||||
{
|
||||
@@ -156,18 +144,12 @@ namespace nowide {
|
||||
{
|
||||
if(!buf_.close())
|
||||
this->setstate(std::ios_base::failbit);
|
||||
else
|
||||
this->clear();
|
||||
}
|
||||
|
||||
internal_buffer_type *rdbuf() const
|
||||
{
|
||||
return const_cast<internal_buffer_type *>(&buf_);
|
||||
}
|
||||
~basic_ofstream()
|
||||
{
|
||||
buf_.close();
|
||||
}
|
||||
|
||||
private:
|
||||
internal_buffer_type buf_;
|
||||
@@ -210,12 +192,9 @@ namespace nowide {
|
||||
void open(char const *file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
|
||||
{
|
||||
if(!buf_.open(file_name, mode))
|
||||
{
|
||||
this->setstate(std::ios_base::failbit);
|
||||
} else
|
||||
{
|
||||
else
|
||||
this->clear();
|
||||
}
|
||||
}
|
||||
bool is_open()
|
||||
{
|
||||
@@ -229,18 +208,12 @@ namespace nowide {
|
||||
{
|
||||
if(!buf_.close())
|
||||
this->setstate(std::ios_base::failbit);
|
||||
else
|
||||
this->clear();
|
||||
}
|
||||
|
||||
internal_buffer_type *rdbuf() const
|
||||
{
|
||||
return const_cast<internal_buffer_type *>(&buf_);
|
||||
}
|
||||
~basic_fstream()
|
||||
{
|
||||
buf_.close();
|
||||
}
|
||||
|
||||
private:
|
||||
internal_buffer_type buf_;
|
||||
|
||||
Reference in New Issue
Block a user