diff --git a/include/osgDB/fstream b/include/osgDB/fstream index b15a2ecfc..cb3c1bdcd 100644 --- a/include/osgDB/fstream +++ b/include/osgDB/fstream @@ -19,26 +19,17 @@ #include + namespace osgDB { /** -* Replacements for std::fstream, std::ifstream, and std::ofstream to +* Convenience function for fstream open , std::ifstream, and std::ofstream to * automatically handle UTF-8 to UTF-16 filename conversion. Always use one * of these classes in any OpenSceneGraph code instead of the STL equivalent. */ -class OSGDB_EXPORT fstream : public std::fstream -{ -public: - fstream(); - explicit fstream(const char* filename, - std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); - ~fstream(); - - void open(const char* filename, - std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); -}; +void OSGDB_EXPORT open(std::fstream& fs, const char* filename,std::ios_base::openmode mode); class OSGDB_EXPORT ifstream : public std::ifstream { diff --git a/src/osgDB/fstream.cpp b/src/osgDB/fstream.cpp index b5d16ff10..19ea29bc0 100644 --- a/src/osgDB/fstream.cpp +++ b/src/osgDB/fstream.cpp @@ -12,6 +12,8 @@ */ #include + + #include #include @@ -25,17 +27,13 @@ namespace osgDB #define OSGDB_CONVERT_UTF8_FILENAME(s) s #endif - fstream::fstream(){} - fstream::fstream(const char* filename, - std::ios_base::openmode mode) : std::fstream(OSGDB_CONVERT_UTF8_FILENAME(filename), mode) - {} - fstream::~fstream(){} - void fstream::open(const char* filename, - std::ios_base::openmode mode) + + void open(std::fstream &fs, const char* filename,std::ios_base::openmode mode) { - std::fstream::open(OSGDB_CONVERT_UTF8_FILENAME(filename), mode); + fs.open(OSGDB_CONVERT_UTF8_FILENAME(filename), mode); } + ifstream::ifstream(){} ifstream::ifstream(const char* filename, std::ios_base::openmode mode) : std::ifstream(OSGDB_CONVERT_UTF8_FILENAME(filename), mode) diff --git a/src/osgPlugins/osga/OSGA_Archive.cpp b/src/osgPlugins/osga/OSGA_Archive.cpp index 4a41b244d..c77396a97 100644 --- a/src/osgPlugins/osga/OSGA_Archive.cpp +++ b/src/osgPlugins/osga/OSGA_Archive.cpp @@ -373,7 +373,7 @@ bool OSGA_Archive::open(const std::string& filename, ArchiveStatus status, unsig _input.close(); _status = WRITE; - _output.open(filename.c_str(), std::ios_base::binary | std::ios_base::in | std::ios_base::out); + osgDB::open(_output, filename.c_str(), std::ios_base::binary | std::ios_base::in | std::ios_base::out); OSG_INFO<<"File position after open = "<(&ENDIAN_TEST_NUMBER),4); _output.write(reinterpret_cast(&s_currentSupportedVersion),sizeof(float)); diff --git a/src/osgPlugins/osga/OSGA_Archive.h b/src/osgPlugins/osga/OSGA_Archive.h index a59e19900..43512723b 100644 --- a/src/osgPlugins/osga/OSGA_Archive.h +++ b/src/osgPlugins/osga/OSGA_Archive.h @@ -217,7 +217,7 @@ class OSGA_Archive : public osgDB::Archive float _version; ArchiveStatus _status; osgDB::ifstream _input; - osgDB::fstream _output; + std::fstream _output; std::string _archiveFileName; std::string _masterFileName;