1 // boost/filesystem/fstream.hpp --------------------------------------------//
3 // (C) Copyright Beman Dawes 2002. Permission to copy, use, modify, sell and
4 // distribute this software is granted provided this copyright notice appears
5 // in all copies. This software is provided "as is" without express or implied
6 // warranty, and with no claim as to its suitability for any purpose.
8 // See http://www.boost.org/libs/filesystem for documentation.
10 //----------------------------------------------------------------------------//
12 #ifndef BOOST_FILESYSTEM_FSTREAM_HPP
13 #define BOOST_FILESYSTEM_FSTREAM_HPP
15 #include <boost/filesystem/path.hpp>
24 template < class charT, class traits = std::char_traits<charT> >
25 class basic_filebuf : public std::basic_filebuf<charT,traits>
28 virtual ~basic_filebuf() {}
30 #if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 // VC++ 6.0 can't handle this
31 std::basic_filebuf<charT,traits> * open( const path & file_ph,
32 std::ios_base::openmode mode )
34 return std::basic_filebuf<charT,traits>::open(
35 file_ph.native_file_string().c_str(), mode );
40 typedef basic_filebuf<char> filebuf;
41 # ifndef BOOST_NO_STD_WSTRING
42 typedef basic_filebuf<wchar_t> wfilebuf;
45 template < class charT, class traits = std::char_traits<charT> >
46 class basic_ifstream : public std::basic_ifstream<charT,traits>
50 explicit basic_ifstream( const path & file_ph,
51 std::ios_base::openmode mode = std::ios_base::in )
52 : std::basic_ifstream<charT,traits>(
53 file_ph.native_file_string().c_str(), mode ) {}
54 virtual ~basic_ifstream() {}
55 #if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 // VC++ 6.0 can't handle this
56 void open( const path & file_ph,
57 std::ios_base::openmode mode = std::ios_base::in )
59 std::basic_ifstream<charT,traits>::open(
60 file_ph.native_file_string().c_str(), mode );
65 typedef basic_ifstream<char> ifstream;
66 # ifndef BOOST_NO_STD_WSTRING
67 typedef basic_ifstream<wchar_t> wifstream;
70 template < class charT, class traits = std::char_traits<charT> >
71 class basic_ofstream : public std::basic_ofstream<charT,traits>
75 explicit basic_ofstream( const path & file_ph,
76 std::ios_base::openmode mode = std::ios_base::out )
77 : std::basic_ofstream<charT,traits>(
78 file_ph.native_file_string().c_str(), mode ) {}
79 virtual ~basic_ofstream() {}
80 #if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 // VC++ 6.0 can't handle this
81 void open( const path & file_ph,
82 std::ios_base::openmode mode = std::ios_base::out )
84 std::basic_ofstream<charT,traits>::open(
85 file_ph.native_file_string().c_str(), mode );
90 typedef basic_ofstream<char> ofstream;
91 # ifndef BOOST_NO_STD_WSTRING
92 typedef basic_ofstream<wchar_t> wofstream;
95 template < class charT, class traits = std::char_traits<charT> >
96 class basic_fstream : public std::basic_fstream<charT,traits>
100 explicit basic_fstream( const path & file_ph,
101 std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out )
102 : std::basic_fstream<charT,traits>(
103 file_ph.native_file_string().c_str(), mode ) {}
104 virtual ~basic_fstream() {}
105 #if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 // VC++ 6.0 can't handle this
106 void open( const path & file_ph,
107 std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out )
109 std::basic_fstream<charT,traits>::open(
110 file_ph.native_file_string().c_str(), mode );
115 typedef basic_fstream<char> fstream;
116 # ifndef BOOST_NO_STD_WSTRING
117 typedef basic_fstream<wchar_t> wfstream;
119 } // namespace filesystem
123 #endif // BOOST_FILESYSTEM_FSTREAM_HPP