iostream overloads taking an SGPath

This commit is contained in:
James Turner 2016-06-25 16:30:24 +01:00
parent 8cfe5a2e08
commit a3b3280123
2 changed files with 29 additions and 2 deletions

View File

@ -193,3 +193,17 @@ sg_gzofstream::attach( int fd, ios_openmode io_mode )
{ {
gzbuf.attach( fd, io_mode ); gzbuf.attach( fd, io_mode );
} }
sg_ifstream::sg_ifstream(const SGPath& path, ios_openmode io_mode)
{
std::string ps = path.local8BitStr();
open(ps.c_str(), io_mode);
}
sg_ofstream::sg_ofstream(const SGPath& path, ios_openmode io_mode)
{
std::string ps = path.local8BitStr();
open(ps.c_str(), io_mode);
}

View File

@ -33,8 +33,9 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
# include <istream> #include <istream>
# include <ostream> #include <ostream>
#include <fstream>
#include <string> #include <string>
@ -171,5 +172,17 @@ private:
void operator= ( const sg_gzofstream& ); void operator= ( const sg_gzofstream& );
}; };
class sg_ifstream : public std::ifstream
{
public:
sg_ifstream(const SGPath& path, ios_openmode io_mode = ios_in | ios_binary);
};
class sg_ofstream : public std::ofstream
{
public:
sg_ofstream(const SGPath& path, ios_openmode io_mode = ios_out | ios_binary);
};
#endif /* _SGSTREAM_HXX */ #endif /* _SGSTREAM_HXX */