diff --git a/include/boost/nowide/filebuf.hpp b/include/boost/nowide/filebuf.hpp index beed78d..c67e22b 100644 --- a/include/boost/nowide/filebuf.hpp +++ b/include/boost/nowide/filebuf.hpp @@ -64,11 +64,7 @@ namespace nowide { virtual ~basic_filebuf() { - if(file_) - { - ::fclose(file_); - file_ = 0; - } + close(); if(own_ && buffer_) delete[] buffer_; } diff --git a/include/boost/nowide/fstream.hpp b/include/boost/nowide/fstream.hpp index cc5afc3..b81b96c 100644 --- a/include/boost/nowide/fstream.hpp +++ b/include/boost/nowide/fstream.hpp @@ -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(&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(&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(&buf_); } - ~basic_fstream() - { - buf_.close(); - } private: internal_buffer_type buf_;