From a3b3280123e1192efe9c10790649b21d87b81b85 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 25 Jun 2016 16:30:24 +0100 Subject: [PATCH] iostream overloads taking an SGPath --- simgear/misc/sgstream.cxx | 14 ++++++++++++++ simgear/misc/sgstream.hxx | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/simgear/misc/sgstream.cxx b/simgear/misc/sgstream.cxx index 44ce90b1..99b19a7a 100644 --- a/simgear/misc/sgstream.cxx +++ b/simgear/misc/sgstream.cxx @@ -193,3 +193,17 @@ sg_gzofstream::attach( int fd, ios_openmode 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); +} \ No newline at end of file diff --git a/simgear/misc/sgstream.hxx b/simgear/misc/sgstream.hxx index 8aa72105..e7a4b12c 100644 --- a/simgear/misc/sgstream.hxx +++ b/simgear/misc/sgstream.hxx @@ -33,8 +33,9 @@ #include -# include -# include +#include +#include +#include #include @@ -171,5 +172,17 @@ private: 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 */