1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*- 2*58b9f456SAndroid Build Coastguard Worker//===------------------------- fstream ------------------------------------===// 3*58b9f456SAndroid Build Coastguard Worker// 4*58b9f456SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 5*58b9f456SAndroid Build Coastguard Worker// 6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open 7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details. 8*58b9f456SAndroid Build Coastguard Worker// 9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 10*58b9f456SAndroid Build Coastguard Worker 11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_FSTREAM 12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_FSTREAM 13*58b9f456SAndroid Build Coastguard Worker 14*58b9f456SAndroid Build Coastguard Worker/* 15*58b9f456SAndroid Build Coastguard Worker fstream synopsis 16*58b9f456SAndroid Build Coastguard Worker 17*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits = char_traits<charT> > 18*58b9f456SAndroid Build Coastguard Workerclass basic_filebuf 19*58b9f456SAndroid Build Coastguard Worker : public basic_streambuf<charT, traits> 20*58b9f456SAndroid Build Coastguard Worker{ 21*58b9f456SAndroid Build Coastguard Workerpublic: 22*58b9f456SAndroid Build Coastguard Worker typedef charT char_type; 23*58b9f456SAndroid Build Coastguard Worker typedef traits traits_type; 24*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 25*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 26*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 27*58b9f456SAndroid Build Coastguard Worker 28*58b9f456SAndroid Build Coastguard Worker // 27.9.1.2 Constructors/destructor: 29*58b9f456SAndroid Build Coastguard Worker basic_filebuf(); 30*58b9f456SAndroid Build Coastguard Worker basic_filebuf(basic_filebuf&& rhs); 31*58b9f456SAndroid Build Coastguard Worker virtual ~basic_filebuf(); 32*58b9f456SAndroid Build Coastguard Worker 33*58b9f456SAndroid Build Coastguard Worker // 27.9.1.3 Assign/swap: 34*58b9f456SAndroid Build Coastguard Worker basic_filebuf& operator=(basic_filebuf&& rhs); 35*58b9f456SAndroid Build Coastguard Worker void swap(basic_filebuf& rhs); 36*58b9f456SAndroid Build Coastguard Worker 37*58b9f456SAndroid Build Coastguard Worker // 27.9.1.4 Members: 38*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 39*58b9f456SAndroid Build Coastguard Worker basic_filebuf* open(const char* s, ios_base::openmode mode); 40*58b9f456SAndroid Build Coastguard Worker basic_filebuf* open(const string& s, ios_base::openmode mode); 41*58b9f456SAndroid Build Coastguard Worker basic_filebuf* open(const filesystem::path& p, ios_base::openmode mode); // C++17 42*58b9f456SAndroid Build Coastguard Worker basic_filebuf* close(); 43*58b9f456SAndroid Build Coastguard Worker 44*58b9f456SAndroid Build Coastguard Workerprotected: 45*58b9f456SAndroid Build Coastguard Worker // 27.9.1.5 Overridden virtual functions: 46*58b9f456SAndroid Build Coastguard Worker virtual streamsize showmanyc(); 47*58b9f456SAndroid Build Coastguard Worker virtual int_type underflow(); 48*58b9f456SAndroid Build Coastguard Worker virtual int_type uflow(); 49*58b9f456SAndroid Build Coastguard Worker virtual int_type pbackfail(int_type c = traits_type::eof()); 50*58b9f456SAndroid Build Coastguard Worker virtual int_type overflow (int_type c = traits_type::eof()); 51*58b9f456SAndroid Build Coastguard Worker virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* s, streamsize n); 52*58b9f456SAndroid Build Coastguard Worker virtual pos_type seekoff(off_type off, ios_base::seekdir way, 53*58b9f456SAndroid Build Coastguard Worker ios_base::openmode which = ios_base::in | ios_base::out); 54*58b9f456SAndroid Build Coastguard Worker virtual pos_type seekpos(pos_type sp, 55*58b9f456SAndroid Build Coastguard Worker ios_base::openmode which = ios_base::in | ios_base::out); 56*58b9f456SAndroid Build Coastguard Worker virtual int sync(); 57*58b9f456SAndroid Build Coastguard Worker virtual void imbue(const locale& loc); 58*58b9f456SAndroid Build Coastguard Worker}; 59*58b9f456SAndroid Build Coastguard Worker 60*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits> 61*58b9f456SAndroid Build Coastguard Worker void 62*58b9f456SAndroid Build Coastguard Worker swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y); 63*58b9f456SAndroid Build Coastguard Worker 64*58b9f456SAndroid Build Coastguard Workertypedef basic_filebuf<char> filebuf; 65*58b9f456SAndroid Build Coastguard Workertypedef basic_filebuf<wchar_t> wfilebuf; 66*58b9f456SAndroid Build Coastguard Worker 67*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits = char_traits<charT> > 68*58b9f456SAndroid Build Coastguard Workerclass basic_ifstream 69*58b9f456SAndroid Build Coastguard Worker : public basic_istream<charT,traits> 70*58b9f456SAndroid Build Coastguard Worker{ 71*58b9f456SAndroid Build Coastguard Workerpublic: 72*58b9f456SAndroid Build Coastguard Worker typedef charT char_type; 73*58b9f456SAndroid Build Coastguard Worker typedef traits traits_type; 74*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 75*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 76*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 77*58b9f456SAndroid Build Coastguard Worker 78*58b9f456SAndroid Build Coastguard Worker basic_ifstream(); 79*58b9f456SAndroid Build Coastguard Worker explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); 80*58b9f456SAndroid Build Coastguard Worker explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in); 81*58b9f456SAndroid Build Coastguard Worker explicit basic_ifstream(const filesystem::path& p, 82*58b9f456SAndroid Build Coastguard Worker ios_base::openmode mode = ios_base::in); // C++17 83*58b9f456SAndroid Build Coastguard Worker basic_ifstream(basic_ifstream&& rhs); 84*58b9f456SAndroid Build Coastguard Worker 85*58b9f456SAndroid Build Coastguard Worker basic_ifstream& operator=(basic_ifstream&& rhs); 86*58b9f456SAndroid Build Coastguard Worker void swap(basic_ifstream& rhs); 87*58b9f456SAndroid Build Coastguard Worker 88*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type>* rdbuf() const; 89*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 90*58b9f456SAndroid Build Coastguard Worker void open(const char* s, ios_base::openmode mode = ios_base::in); 91*58b9f456SAndroid Build Coastguard Worker void open(const string& s, ios_base::openmode mode = ios_base::in); 92*58b9f456SAndroid Build Coastguard Worker void open(const filesystem::path& s, ios_base::openmode mode = ios_base::in); // C++17 93*58b9f456SAndroid Build Coastguard Worker 94*58b9f456SAndroid Build Coastguard Worker void close(); 95*58b9f456SAndroid Build Coastguard Worker}; 96*58b9f456SAndroid Build Coastguard Worker 97*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits> 98*58b9f456SAndroid Build Coastguard Worker void 99*58b9f456SAndroid Build Coastguard Worker swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y); 100*58b9f456SAndroid Build Coastguard Worker 101*58b9f456SAndroid Build Coastguard Workertypedef basic_ifstream<char> ifstream; 102*58b9f456SAndroid Build Coastguard Workertypedef basic_ifstream<wchar_t> wifstream; 103*58b9f456SAndroid Build Coastguard Worker 104*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits = char_traits<charT> > 105*58b9f456SAndroid Build Coastguard Workerclass basic_ofstream 106*58b9f456SAndroid Build Coastguard Worker : public basic_ostream<charT,traits> 107*58b9f456SAndroid Build Coastguard Worker{ 108*58b9f456SAndroid Build Coastguard Workerpublic: 109*58b9f456SAndroid Build Coastguard Worker typedef charT char_type; 110*58b9f456SAndroid Build Coastguard Worker typedef traits traits_type; 111*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 112*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 113*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 114*58b9f456SAndroid Build Coastguard Worker 115*58b9f456SAndroid Build Coastguard Worker basic_ofstream(); 116*58b9f456SAndroid Build Coastguard Worker explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out); 117*58b9f456SAndroid Build Coastguard Worker explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out); 118*58b9f456SAndroid Build Coastguard Worker explicit basic_ofstream(const filesystem::path& p, 119*58b9f456SAndroid Build Coastguard Worker ios_base::openmode mode = ios_base::out); // C++17 120*58b9f456SAndroid Build Coastguard Worker basic_ofstream(basic_ofstream&& rhs); 121*58b9f456SAndroid Build Coastguard Worker 122*58b9f456SAndroid Build Coastguard Worker basic_ofstream& operator=(basic_ofstream&& rhs); 123*58b9f456SAndroid Build Coastguard Worker void swap(basic_ofstream& rhs); 124*58b9f456SAndroid Build Coastguard Worker 125*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type>* rdbuf() const; 126*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 127*58b9f456SAndroid Build Coastguard Worker void open(const char* s, ios_base::openmode mode = ios_base::out); 128*58b9f456SAndroid Build Coastguard Worker void open(const string& s, ios_base::openmode mode = ios_base::out); 129*58b9f456SAndroid Build Coastguard Worker void open(const filesystem::path& p, 130*58b9f456SAndroid Build Coastguard Worker ios_base::openmode mode = ios_base::out); // C++17 131*58b9f456SAndroid Build Coastguard Worker 132*58b9f456SAndroid Build Coastguard Worker void close(); 133*58b9f456SAndroid Build Coastguard Worker}; 134*58b9f456SAndroid Build Coastguard Worker 135*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits> 136*58b9f456SAndroid Build Coastguard Worker void 137*58b9f456SAndroid Build Coastguard Worker swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y); 138*58b9f456SAndroid Build Coastguard Worker 139*58b9f456SAndroid Build Coastguard Workertypedef basic_ofstream<char> ofstream; 140*58b9f456SAndroid Build Coastguard Workertypedef basic_ofstream<wchar_t> wofstream; 141*58b9f456SAndroid Build Coastguard Worker 142*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits=char_traits<charT> > 143*58b9f456SAndroid Build Coastguard Workerclass basic_fstream 144*58b9f456SAndroid Build Coastguard Worker : public basic_iostream<charT,traits> 145*58b9f456SAndroid Build Coastguard Worker{ 146*58b9f456SAndroid Build Coastguard Workerpublic: 147*58b9f456SAndroid Build Coastguard Worker typedef charT char_type; 148*58b9f456SAndroid Build Coastguard Worker typedef traits traits_type; 149*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 150*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 151*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 152*58b9f456SAndroid Build Coastguard Worker 153*58b9f456SAndroid Build Coastguard Worker basic_fstream(); 154*58b9f456SAndroid Build Coastguard Worker explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out); 155*58b9f456SAndroid Build Coastguard Worker explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); 156*58b9f456SAndroid Build Coastguard Worker explicit basic_fstream(const filesystem::path& p, 157*58b9f456SAndroid Build Coastguard Worker ios_base::openmode mode = ios_base::in|ios_base::out); C++17 158*58b9f456SAndroid Build Coastguard Worker basic_fstream(basic_fstream&& rhs); 159*58b9f456SAndroid Build Coastguard Worker 160*58b9f456SAndroid Build Coastguard Worker basic_fstream& operator=(basic_fstream&& rhs); 161*58b9f456SAndroid Build Coastguard Worker void swap(basic_fstream& rhs); 162*58b9f456SAndroid Build Coastguard Worker 163*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type>* rdbuf() const; 164*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 165*58b9f456SAndroid Build Coastguard Worker void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out); 166*58b9f456SAndroid Build Coastguard Worker void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); 167*58b9f456SAndroid Build Coastguard Worker void open(const filesystem::path& s, 168*58b9f456SAndroid Build Coastguard Worker ios_base::openmode mode = ios_base::in|ios_base::out); // C++17 169*58b9f456SAndroid Build Coastguard Worker 170*58b9f456SAndroid Build Coastguard Worker void close(); 171*58b9f456SAndroid Build Coastguard Worker}; 172*58b9f456SAndroid Build Coastguard Worker 173*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits> 174*58b9f456SAndroid Build Coastguard Worker void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y); 175*58b9f456SAndroid Build Coastguard Worker 176*58b9f456SAndroid Build Coastguard Workertypedef basic_fstream<char> fstream; 177*58b9f456SAndroid Build Coastguard Workertypedef basic_fstream<wchar_t> wfstream; 178*58b9f456SAndroid Build Coastguard Worker 179*58b9f456SAndroid Build Coastguard Worker} // std 180*58b9f456SAndroid Build Coastguard Worker 181*58b9f456SAndroid Build Coastguard Worker*/ 182*58b9f456SAndroid Build Coastguard Worker 183*58b9f456SAndroid Build Coastguard Worker#include <__config> 184*58b9f456SAndroid Build Coastguard Worker#include <ostream> 185*58b9f456SAndroid Build Coastguard Worker#include <istream> 186*58b9f456SAndroid Build Coastguard Worker#include <__locale> 187*58b9f456SAndroid Build Coastguard Worker#include <cstdio> 188*58b9f456SAndroid Build Coastguard Worker#include <cstdlib> 189*58b9f456SAndroid Build Coastguard Worker#include <filesystem> 190*58b9f456SAndroid Build Coastguard Worker 191*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 192*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header 193*58b9f456SAndroid Build Coastguard Worker#endif 194*58b9f456SAndroid Build Coastguard Worker 195*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS 196*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros> 197*58b9f456SAndroid Build Coastguard Worker 198*58b9f456SAndroid Build Coastguard Worker 199*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD 200*58b9f456SAndroid Build Coastguard Worker 201*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 202*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_filebuf 203*58b9f456SAndroid Build Coastguard Worker : public basic_streambuf<_CharT, _Traits> 204*58b9f456SAndroid Build Coastguard Worker{ 205*58b9f456SAndroid Build Coastguard Workerpublic: 206*58b9f456SAndroid Build Coastguard Worker typedef _CharT char_type; 207*58b9f456SAndroid Build Coastguard Worker typedef _Traits traits_type; 208*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 209*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 210*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 211*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::state_type state_type; 212*58b9f456SAndroid Build Coastguard Worker 213*58b9f456SAndroid Build Coastguard Worker // 27.9.1.2 Constructors/destructor: 214*58b9f456SAndroid Build Coastguard Worker basic_filebuf(); 215*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 216*58b9f456SAndroid Build Coastguard Worker basic_filebuf(basic_filebuf&& __rhs); 217*58b9f456SAndroid Build Coastguard Worker#endif 218*58b9f456SAndroid Build Coastguard Worker virtual ~basic_filebuf(); 219*58b9f456SAndroid Build Coastguard Worker 220*58b9f456SAndroid Build Coastguard Worker // 27.9.1.3 Assign/swap: 221*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 222*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 223*58b9f456SAndroid Build Coastguard Worker basic_filebuf& operator=(basic_filebuf&& __rhs); 224*58b9f456SAndroid Build Coastguard Worker#endif 225*58b9f456SAndroid Build Coastguard Worker void swap(basic_filebuf& __rhs); 226*58b9f456SAndroid Build Coastguard Worker 227*58b9f456SAndroid Build Coastguard Worker // 27.9.1.4 Members: 228*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 229*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 230*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 231*58b9f456SAndroid Build Coastguard Worker basic_filebuf* open(const char* __s, ios_base::openmode __mode); 232*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 233*58b9f456SAndroid Build Coastguard Worker basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode); 234*58b9f456SAndroid Build Coastguard Worker#endif 235*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 236*58b9f456SAndroid Build Coastguard Worker basic_filebuf* open(const string& __s, ios_base::openmode __mode); 237*58b9f456SAndroid Build Coastguard Worker 238*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 17 239*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 240*58b9f456SAndroid Build Coastguard Worker basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) { 241*58b9f456SAndroid Build Coastguard Worker return open(__p.c_str(), __mode); 242*58b9f456SAndroid Build Coastguard Worker } 243*58b9f456SAndroid Build Coastguard Worker#endif 244*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 245*58b9f456SAndroid Build Coastguard Worker basic_filebuf* __open(int __fd, ios_base::openmode __mode); 246*58b9f456SAndroid Build Coastguard Worker#endif 247*58b9f456SAndroid Build Coastguard Worker basic_filebuf* close(); 248*58b9f456SAndroid Build Coastguard Worker 249*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 250*58b9f456SAndroid Build Coastguard Worker inline static const char* 251*58b9f456SAndroid Build Coastguard Worker __make_mdstring(ios_base::openmode __mode) _NOEXCEPT; 252*58b9f456SAndroid Build Coastguard Worker 253*58b9f456SAndroid Build Coastguard Worker protected: 254*58b9f456SAndroid Build Coastguard Worker // 27.9.1.5 Overridden virtual functions: 255*58b9f456SAndroid Build Coastguard Worker virtual int_type underflow(); 256*58b9f456SAndroid Build Coastguard Worker virtual int_type pbackfail(int_type __c = traits_type::eof()); 257*58b9f456SAndroid Build Coastguard Worker virtual int_type overflow (int_type __c = traits_type::eof()); 258*58b9f456SAndroid Build Coastguard Worker virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n); 259*58b9f456SAndroid Build Coastguard Worker virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, 260*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __wch = ios_base::in | ios_base::out); 261*58b9f456SAndroid Build Coastguard Worker virtual pos_type seekpos(pos_type __sp, 262*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __wch = ios_base::in | ios_base::out); 263*58b9f456SAndroid Build Coastguard Worker virtual int sync(); 264*58b9f456SAndroid Build Coastguard Worker virtual void imbue(const locale& __loc); 265*58b9f456SAndroid Build Coastguard Worker 266*58b9f456SAndroid Build Coastguard Workerprivate: 267*58b9f456SAndroid Build Coastguard Worker char* __extbuf_; 268*58b9f456SAndroid Build Coastguard Worker const char* __extbufnext_; 269*58b9f456SAndroid Build Coastguard Worker const char* __extbufend_; 270*58b9f456SAndroid Build Coastguard Worker char __extbuf_min_[8]; 271*58b9f456SAndroid Build Coastguard Worker size_t __ebs_; 272*58b9f456SAndroid Build Coastguard Worker char_type* __intbuf_; 273*58b9f456SAndroid Build Coastguard Worker size_t __ibs_; 274*58b9f456SAndroid Build Coastguard Worker FILE* __file_; 275*58b9f456SAndroid Build Coastguard Worker const codecvt<char_type, char, state_type>* __cv_; 276*58b9f456SAndroid Build Coastguard Worker state_type __st_; 277*58b9f456SAndroid Build Coastguard Worker state_type __st_last_; 278*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __om_; 279*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __cm_; 280*58b9f456SAndroid Build Coastguard Worker bool __owns_eb_; 281*58b9f456SAndroid Build Coastguard Worker bool __owns_ib_; 282*58b9f456SAndroid Build Coastguard Worker bool __always_noconv_; 283*58b9f456SAndroid Build Coastguard Worker 284*58b9f456SAndroid Build Coastguard Worker bool __read_mode(); 285*58b9f456SAndroid Build Coastguard Worker void __write_mode(); 286*58b9f456SAndroid Build Coastguard Worker}; 287*58b9f456SAndroid Build Coastguard Worker 288*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 289*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::basic_filebuf() 290*58b9f456SAndroid Build Coastguard Worker : __extbuf_(0), 291*58b9f456SAndroid Build Coastguard Worker __extbufnext_(0), 292*58b9f456SAndroid Build Coastguard Worker __extbufend_(0), 293*58b9f456SAndroid Build Coastguard Worker __ebs_(0), 294*58b9f456SAndroid Build Coastguard Worker __intbuf_(0), 295*58b9f456SAndroid Build Coastguard Worker __ibs_(0), 296*58b9f456SAndroid Build Coastguard Worker __file_(0), 297*58b9f456SAndroid Build Coastguard Worker __cv_(nullptr), 298*58b9f456SAndroid Build Coastguard Worker __st_(), 299*58b9f456SAndroid Build Coastguard Worker __st_last_(), 300*58b9f456SAndroid Build Coastguard Worker __om_(0), 301*58b9f456SAndroid Build Coastguard Worker __cm_(0), 302*58b9f456SAndroid Build Coastguard Worker __owns_eb_(false), 303*58b9f456SAndroid Build Coastguard Worker __owns_ib_(false), 304*58b9f456SAndroid Build Coastguard Worker __always_noconv_(false) 305*58b9f456SAndroid Build Coastguard Worker{ 306*58b9f456SAndroid Build Coastguard Worker if (has_facet<codecvt<char_type, char, state_type> >(this->getloc())) 307*58b9f456SAndroid Build Coastguard Worker { 308*58b9f456SAndroid Build Coastguard Worker __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc()); 309*58b9f456SAndroid Build Coastguard Worker __always_noconv_ = __cv_->always_noconv(); 310*58b9f456SAndroid Build Coastguard Worker } 311*58b9f456SAndroid Build Coastguard Worker setbuf(0, 4096); 312*58b9f456SAndroid Build Coastguard Worker} 313*58b9f456SAndroid Build Coastguard Worker 314*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 315*58b9f456SAndroid Build Coastguard Worker 316*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 317*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs) 318*58b9f456SAndroid Build Coastguard Worker : basic_streambuf<_CharT, _Traits>(__rhs) 319*58b9f456SAndroid Build Coastguard Worker{ 320*58b9f456SAndroid Build Coastguard Worker if (__rhs.__extbuf_ == __rhs.__extbuf_min_) 321*58b9f456SAndroid Build Coastguard Worker { 322*58b9f456SAndroid Build Coastguard Worker __extbuf_ = __extbuf_min_; 323*58b9f456SAndroid Build Coastguard Worker __extbufnext_ = __extbuf_ + (__rhs.__extbufnext_ - __rhs.__extbuf_); 324*58b9f456SAndroid Build Coastguard Worker __extbufend_ = __extbuf_ + (__rhs.__extbufend_ - __rhs.__extbuf_); 325*58b9f456SAndroid Build Coastguard Worker } 326*58b9f456SAndroid Build Coastguard Worker else 327*58b9f456SAndroid Build Coastguard Worker { 328*58b9f456SAndroid Build Coastguard Worker __extbuf_ = __rhs.__extbuf_; 329*58b9f456SAndroid Build Coastguard Worker __extbufnext_ = __rhs.__extbufnext_; 330*58b9f456SAndroid Build Coastguard Worker __extbufend_ = __rhs.__extbufend_; 331*58b9f456SAndroid Build Coastguard Worker } 332*58b9f456SAndroid Build Coastguard Worker __ebs_ = __rhs.__ebs_; 333*58b9f456SAndroid Build Coastguard Worker __intbuf_ = __rhs.__intbuf_; 334*58b9f456SAndroid Build Coastguard Worker __ibs_ = __rhs.__ibs_; 335*58b9f456SAndroid Build Coastguard Worker __file_ = __rhs.__file_; 336*58b9f456SAndroid Build Coastguard Worker __cv_ = __rhs.__cv_; 337*58b9f456SAndroid Build Coastguard Worker __st_ = __rhs.__st_; 338*58b9f456SAndroid Build Coastguard Worker __st_last_ = __rhs.__st_last_; 339*58b9f456SAndroid Build Coastguard Worker __om_ = __rhs.__om_; 340*58b9f456SAndroid Build Coastguard Worker __cm_ = __rhs.__cm_; 341*58b9f456SAndroid Build Coastguard Worker __owns_eb_ = __rhs.__owns_eb_; 342*58b9f456SAndroid Build Coastguard Worker __owns_ib_ = __rhs.__owns_ib_; 343*58b9f456SAndroid Build Coastguard Worker __always_noconv_ = __rhs.__always_noconv_; 344*58b9f456SAndroid Build Coastguard Worker if (__rhs.pbase()) 345*58b9f456SAndroid Build Coastguard Worker { 346*58b9f456SAndroid Build Coastguard Worker if (__rhs.pbase() == __rhs.__intbuf_) 347*58b9f456SAndroid Build Coastguard Worker this->setp(__intbuf_, __intbuf_ + (__rhs. epptr() - __rhs.pbase())); 348*58b9f456SAndroid Build Coastguard Worker else 349*58b9f456SAndroid Build Coastguard Worker this->setp((char_type*)__extbuf_, 350*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase())); 351*58b9f456SAndroid Build Coastguard Worker this->__pbump(__rhs. pptr() - __rhs.pbase()); 352*58b9f456SAndroid Build Coastguard Worker } 353*58b9f456SAndroid Build Coastguard Worker else if (__rhs.eback()) 354*58b9f456SAndroid Build Coastguard Worker { 355*58b9f456SAndroid Build Coastguard Worker if (__rhs.eback() == __rhs.__intbuf_) 356*58b9f456SAndroid Build Coastguard Worker this->setg(__intbuf_, __intbuf_ + (__rhs.gptr() - __rhs.eback()), 357*58b9f456SAndroid Build Coastguard Worker __intbuf_ + (__rhs.egptr() - __rhs.eback())); 358*58b9f456SAndroid Build Coastguard Worker else 359*58b9f456SAndroid Build Coastguard Worker this->setg((char_type*)__extbuf_, 360*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()), 361*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback())); 362*58b9f456SAndroid Build Coastguard Worker } 363*58b9f456SAndroid Build Coastguard Worker __rhs.__extbuf_ = 0; 364*58b9f456SAndroid Build Coastguard Worker __rhs.__extbufnext_ = 0; 365*58b9f456SAndroid Build Coastguard Worker __rhs.__extbufend_ = 0; 366*58b9f456SAndroid Build Coastguard Worker __rhs.__ebs_ = 0; 367*58b9f456SAndroid Build Coastguard Worker __rhs.__intbuf_ = 0; 368*58b9f456SAndroid Build Coastguard Worker __rhs.__ibs_ = 0; 369*58b9f456SAndroid Build Coastguard Worker __rhs.__file_ = 0; 370*58b9f456SAndroid Build Coastguard Worker __rhs.__st_ = state_type(); 371*58b9f456SAndroid Build Coastguard Worker __rhs.__st_last_ = state_type(); 372*58b9f456SAndroid Build Coastguard Worker __rhs.__om_ = 0; 373*58b9f456SAndroid Build Coastguard Worker __rhs.__cm_ = 0; 374*58b9f456SAndroid Build Coastguard Worker __rhs.__owns_eb_ = false; 375*58b9f456SAndroid Build Coastguard Worker __rhs.__owns_ib_ = false; 376*58b9f456SAndroid Build Coastguard Worker __rhs.setg(0, 0, 0); 377*58b9f456SAndroid Build Coastguard Worker __rhs.setp(0, 0); 378*58b9f456SAndroid Build Coastguard Worker} 379*58b9f456SAndroid Build Coastguard Worker 380*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 381*58b9f456SAndroid Build Coastguard Workerinline 382*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>& 383*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs) 384*58b9f456SAndroid Build Coastguard Worker{ 385*58b9f456SAndroid Build Coastguard Worker close(); 386*58b9f456SAndroid Build Coastguard Worker swap(__rhs); 387*58b9f456SAndroid Build Coastguard Worker return *this; 388*58b9f456SAndroid Build Coastguard Worker} 389*58b9f456SAndroid Build Coastguard Worker 390*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG 391*58b9f456SAndroid Build Coastguard Worker 392*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 393*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::~basic_filebuf() 394*58b9f456SAndroid Build Coastguard Worker{ 395*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 396*58b9f456SAndroid Build Coastguard Worker try 397*58b9f456SAndroid Build Coastguard Worker { 398*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 399*58b9f456SAndroid Build Coastguard Worker close(); 400*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS 401*58b9f456SAndroid Build Coastguard Worker } 402*58b9f456SAndroid Build Coastguard Worker catch (...) 403*58b9f456SAndroid Build Coastguard Worker { 404*58b9f456SAndroid Build Coastguard Worker } 405*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_NO_EXCEPTIONS 406*58b9f456SAndroid Build Coastguard Worker if (__owns_eb_) 407*58b9f456SAndroid Build Coastguard Worker delete [] __extbuf_; 408*58b9f456SAndroid Build Coastguard Worker if (__owns_ib_) 409*58b9f456SAndroid Build Coastguard Worker delete [] __intbuf_; 410*58b9f456SAndroid Build Coastguard Worker} 411*58b9f456SAndroid Build Coastguard Worker 412*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 413*58b9f456SAndroid Build Coastguard Workervoid 414*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs) 415*58b9f456SAndroid Build Coastguard Worker{ 416*58b9f456SAndroid Build Coastguard Worker basic_streambuf<char_type, traits_type>::swap(__rhs); 417*58b9f456SAndroid Build Coastguard Worker if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_) 418*58b9f456SAndroid Build Coastguard Worker { 419*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__extbuf_, __rhs.__extbuf_); 420*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__extbufnext_, __rhs.__extbufnext_); 421*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__extbufend_, __rhs.__extbufend_); 422*58b9f456SAndroid Build Coastguard Worker } 423*58b9f456SAndroid Build Coastguard Worker else 424*58b9f456SAndroid Build Coastguard Worker { 425*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __ln = __extbufnext_ - __extbuf_; 426*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __le = __extbufend_ - __extbuf_; 427*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_; 428*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_; 429*58b9f456SAndroid Build Coastguard Worker if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_) 430*58b9f456SAndroid Build Coastguard Worker { 431*58b9f456SAndroid Build Coastguard Worker __extbuf_ = __rhs.__extbuf_; 432*58b9f456SAndroid Build Coastguard Worker __rhs.__extbuf_ = __rhs.__extbuf_min_; 433*58b9f456SAndroid Build Coastguard Worker } 434*58b9f456SAndroid Build Coastguard Worker else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_) 435*58b9f456SAndroid Build Coastguard Worker { 436*58b9f456SAndroid Build Coastguard Worker __rhs.__extbuf_ = __extbuf_; 437*58b9f456SAndroid Build Coastguard Worker __extbuf_ = __extbuf_min_; 438*58b9f456SAndroid Build Coastguard Worker } 439*58b9f456SAndroid Build Coastguard Worker __extbufnext_ = __extbuf_ + __rn; 440*58b9f456SAndroid Build Coastguard Worker __extbufend_ = __extbuf_ + __re; 441*58b9f456SAndroid Build Coastguard Worker __rhs.__extbufnext_ = __rhs.__extbuf_ + __ln; 442*58b9f456SAndroid Build Coastguard Worker __rhs.__extbufend_ = __rhs.__extbuf_ + __le; 443*58b9f456SAndroid Build Coastguard Worker } 444*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__ebs_, __rhs.__ebs_); 445*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__intbuf_, __rhs.__intbuf_); 446*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__ibs_, __rhs.__ibs_); 447*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__file_, __rhs.__file_); 448*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__cv_, __rhs.__cv_); 449*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__st_, __rhs.__st_); 450*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__st_last_, __rhs.__st_last_); 451*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__om_, __rhs.__om_); 452*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__cm_, __rhs.__cm_); 453*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__owns_eb_, __rhs.__owns_eb_); 454*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__owns_ib_, __rhs.__owns_ib_); 455*58b9f456SAndroid Build Coastguard Worker _VSTD::swap(__always_noconv_, __rhs.__always_noconv_); 456*58b9f456SAndroid Build Coastguard Worker if (this->eback() == (char_type*)__rhs.__extbuf_min_) 457*58b9f456SAndroid Build Coastguard Worker { 458*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __n = this->gptr() - this->eback(); 459*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __e = this->egptr() - this->eback(); 460*58b9f456SAndroid Build Coastguard Worker this->setg((char_type*)__extbuf_min_, 461*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_min_ + __n, 462*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_min_ + __e); 463*58b9f456SAndroid Build Coastguard Worker } 464*58b9f456SAndroid Build Coastguard Worker else if (this->pbase() == (char_type*)__rhs.__extbuf_min_) 465*58b9f456SAndroid Build Coastguard Worker { 466*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __n = this->pptr() - this->pbase(); 467*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __e = this->epptr() - this->pbase(); 468*58b9f456SAndroid Build Coastguard Worker this->setp((char_type*)__extbuf_min_, 469*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_min_ + __e); 470*58b9f456SAndroid Build Coastguard Worker this->__pbump(__n); 471*58b9f456SAndroid Build Coastguard Worker } 472*58b9f456SAndroid Build Coastguard Worker if (__rhs.eback() == (char_type*)__extbuf_min_) 473*58b9f456SAndroid Build Coastguard Worker { 474*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __n = __rhs.gptr() - __rhs.eback(); 475*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __e = __rhs.egptr() - __rhs.eback(); 476*58b9f456SAndroid Build Coastguard Worker __rhs.setg((char_type*)__rhs.__extbuf_min_, 477*58b9f456SAndroid Build Coastguard Worker (char_type*)__rhs.__extbuf_min_ + __n, 478*58b9f456SAndroid Build Coastguard Worker (char_type*)__rhs.__extbuf_min_ + __e); 479*58b9f456SAndroid Build Coastguard Worker } 480*58b9f456SAndroid Build Coastguard Worker else if (__rhs.pbase() == (char_type*)__extbuf_min_) 481*58b9f456SAndroid Build Coastguard Worker { 482*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __n = __rhs.pptr() - __rhs.pbase(); 483*58b9f456SAndroid Build Coastguard Worker ptrdiff_t __e = __rhs.epptr() - __rhs.pbase(); 484*58b9f456SAndroid Build Coastguard Worker __rhs.setp((char_type*)__rhs.__extbuf_min_, 485*58b9f456SAndroid Build Coastguard Worker (char_type*)__rhs.__extbuf_min_ + __e); 486*58b9f456SAndroid Build Coastguard Worker __rhs.__pbump(__n); 487*58b9f456SAndroid Build Coastguard Worker } 488*58b9f456SAndroid Build Coastguard Worker} 489*58b9f456SAndroid Build Coastguard Worker 490*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 491*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 492*58b9f456SAndroid Build Coastguard Workervoid 493*58b9f456SAndroid Build Coastguard Workerswap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y) 494*58b9f456SAndroid Build Coastguard Worker{ 495*58b9f456SAndroid Build Coastguard Worker __x.swap(__y); 496*58b9f456SAndroid Build Coastguard Worker} 497*58b9f456SAndroid Build Coastguard Worker 498*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 499*58b9f456SAndroid Build Coastguard Workerinline 500*58b9f456SAndroid Build Coastguard Workerbool 501*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::is_open() const 502*58b9f456SAndroid Build Coastguard Worker{ 503*58b9f456SAndroid Build Coastguard Worker return __file_ != 0; 504*58b9f456SAndroid Build Coastguard Worker} 505*58b9f456SAndroid Build Coastguard Worker 506*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 507*58b9f456SAndroid Build Coastguard Workerconst char* basic_filebuf<_CharT, _Traits>::__make_mdstring( 508*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __mode) _NOEXCEPT { 509*58b9f456SAndroid Build Coastguard Worker switch (__mode & ~ios_base::ate) { 510*58b9f456SAndroid Build Coastguard Worker case ios_base::out: 511*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::trunc: 512*58b9f456SAndroid Build Coastguard Worker return "w"; 513*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::app: 514*58b9f456SAndroid Build Coastguard Worker case ios_base::app: 515*58b9f456SAndroid Build Coastguard Worker return "a"; 516*58b9f456SAndroid Build Coastguard Worker case ios_base::in: 517*58b9f456SAndroid Build Coastguard Worker return "r"; 518*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out: 519*58b9f456SAndroid Build Coastguard Worker return "r+"; 520*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::trunc: 521*58b9f456SAndroid Build Coastguard Worker return "w+"; 522*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::app: 523*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::app: 524*58b9f456SAndroid Build Coastguard Worker return "a+"; 525*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::binary: 526*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::trunc | ios_base::binary: 527*58b9f456SAndroid Build Coastguard Worker return "wb"; 528*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::app | ios_base::binary: 529*58b9f456SAndroid Build Coastguard Worker case ios_base::app | ios_base::binary: 530*58b9f456SAndroid Build Coastguard Worker return "ab"; 531*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::binary: 532*58b9f456SAndroid Build Coastguard Worker return "rb"; 533*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::binary: 534*58b9f456SAndroid Build Coastguard Worker return "r+b"; 535*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary: 536*58b9f456SAndroid Build Coastguard Worker return "w+b"; 537*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: 538*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::app | ios_base::binary: 539*58b9f456SAndroid Build Coastguard Worker return "a+b"; 540*58b9f456SAndroid Build Coastguard Worker default: 541*58b9f456SAndroid Build Coastguard Worker return nullptr; 542*58b9f456SAndroid Build Coastguard Worker } 543*58b9f456SAndroid Build Coastguard Worker _LIBCPP_UNREACHABLE(); 544*58b9f456SAndroid Build Coastguard Worker} 545*58b9f456SAndroid Build Coastguard Worker 546*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 547*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 548*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>* 549*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) 550*58b9f456SAndroid Build Coastguard Worker{ 551*58b9f456SAndroid Build Coastguard Worker basic_filebuf<_CharT, _Traits>* __rt = 0; 552*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0) 553*58b9f456SAndroid Build Coastguard Worker { 554*58b9f456SAndroid Build Coastguard Worker if (const char* __mdstr = __make_mdstring(__mode)) { 555*58b9f456SAndroid Build Coastguard Worker __rt = this; 556*58b9f456SAndroid Build Coastguard Worker __file_ = fopen(__s, __mdstr); 557*58b9f456SAndroid Build Coastguard Worker if (__file_) { 558*58b9f456SAndroid Build Coastguard Worker __om_ = __mode; 559*58b9f456SAndroid Build Coastguard Worker if (__mode & ios_base::ate) { 560*58b9f456SAndroid Build Coastguard Worker if (fseek(__file_, 0, SEEK_END)) { 561*58b9f456SAndroid Build Coastguard Worker fclose(__file_); 562*58b9f456SAndroid Build Coastguard Worker __file_ = 0; 563*58b9f456SAndroid Build Coastguard Worker __rt = 0; 564*58b9f456SAndroid Build Coastguard Worker } 565*58b9f456SAndroid Build Coastguard Worker } 566*58b9f456SAndroid Build Coastguard Worker } else 567*58b9f456SAndroid Build Coastguard Worker __rt = 0; 568*58b9f456SAndroid Build Coastguard Worker } 569*58b9f456SAndroid Build Coastguard Worker } 570*58b9f456SAndroid Build Coastguard Worker return __rt; 571*58b9f456SAndroid Build Coastguard Worker} 572*58b9f456SAndroid Build Coastguard Worker 573*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 574*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY basic_filebuf<_CharT, _Traits>* 575*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) { 576*58b9f456SAndroid Build Coastguard Worker basic_filebuf<_CharT, _Traits>* __rt = 0; 577*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0) { 578*58b9f456SAndroid Build Coastguard Worker if (const char* __mdstr = __make_mdstring(__mode)) { 579*58b9f456SAndroid Build Coastguard Worker __rt = this; 580*58b9f456SAndroid Build Coastguard Worker __file_ = fdopen(__fd, __mdstr); 581*58b9f456SAndroid Build Coastguard Worker if (__file_) { 582*58b9f456SAndroid Build Coastguard Worker __om_ = __mode; 583*58b9f456SAndroid Build Coastguard Worker if (__mode & ios_base::ate) { 584*58b9f456SAndroid Build Coastguard Worker if (fseek(__file_, 0, SEEK_END)) { 585*58b9f456SAndroid Build Coastguard Worker fclose(__file_); 586*58b9f456SAndroid Build Coastguard Worker __file_ = 0; 587*58b9f456SAndroid Build Coastguard Worker __rt = 0; 588*58b9f456SAndroid Build Coastguard Worker } 589*58b9f456SAndroid Build Coastguard Worker } 590*58b9f456SAndroid Build Coastguard Worker } else 591*58b9f456SAndroid Build Coastguard Worker __rt = 0; 592*58b9f456SAndroid Build Coastguard Worker } 593*58b9f456SAndroid Build Coastguard Worker } 594*58b9f456SAndroid Build Coastguard Worker return __rt; 595*58b9f456SAndroid Build Coastguard Worker} 596*58b9f456SAndroid Build Coastguard Worker 597*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 598*58b9f456SAndroid Build Coastguard Worker// This is basically the same as the char* overload except that it uses _wfopen 599*58b9f456SAndroid Build Coastguard Worker// and long mode strings. 600*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 601*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>* 602*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) 603*58b9f456SAndroid Build Coastguard Worker{ 604*58b9f456SAndroid Build Coastguard Worker basic_filebuf<_CharT, _Traits>* __rt = 0; 605*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0) 606*58b9f456SAndroid Build Coastguard Worker { 607*58b9f456SAndroid Build Coastguard Worker __rt = this; 608*58b9f456SAndroid Build Coastguard Worker const wchar_t* __mdstr; 609*58b9f456SAndroid Build Coastguard Worker switch (__mode & ~ios_base::ate) 610*58b9f456SAndroid Build Coastguard Worker { 611*58b9f456SAndroid Build Coastguard Worker case ios_base::out: 612*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::trunc: 613*58b9f456SAndroid Build Coastguard Worker __mdstr = L"w"; 614*58b9f456SAndroid Build Coastguard Worker break; 615*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::app: 616*58b9f456SAndroid Build Coastguard Worker case ios_base::app: 617*58b9f456SAndroid Build Coastguard Worker __mdstr = L"a"; 618*58b9f456SAndroid Build Coastguard Worker break; 619*58b9f456SAndroid Build Coastguard Worker case ios_base::in: 620*58b9f456SAndroid Build Coastguard Worker __mdstr = L"r"; 621*58b9f456SAndroid Build Coastguard Worker break; 622*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out: 623*58b9f456SAndroid Build Coastguard Worker __mdstr = L"r+"; 624*58b9f456SAndroid Build Coastguard Worker break; 625*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::trunc: 626*58b9f456SAndroid Build Coastguard Worker __mdstr = L"w+"; 627*58b9f456SAndroid Build Coastguard Worker break; 628*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::app: 629*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::app: 630*58b9f456SAndroid Build Coastguard Worker __mdstr = L"a+"; 631*58b9f456SAndroid Build Coastguard Worker break; 632*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::binary: 633*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::trunc | ios_base::binary: 634*58b9f456SAndroid Build Coastguard Worker __mdstr = L"wb"; 635*58b9f456SAndroid Build Coastguard Worker break; 636*58b9f456SAndroid Build Coastguard Worker case ios_base::out | ios_base::app | ios_base::binary: 637*58b9f456SAndroid Build Coastguard Worker case ios_base::app | ios_base::binary: 638*58b9f456SAndroid Build Coastguard Worker __mdstr = L"ab"; 639*58b9f456SAndroid Build Coastguard Worker break; 640*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::binary: 641*58b9f456SAndroid Build Coastguard Worker __mdstr = L"rb"; 642*58b9f456SAndroid Build Coastguard Worker break; 643*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::binary: 644*58b9f456SAndroid Build Coastguard Worker __mdstr = L"r+b"; 645*58b9f456SAndroid Build Coastguard Worker break; 646*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary: 647*58b9f456SAndroid Build Coastguard Worker __mdstr = L"w+b"; 648*58b9f456SAndroid Build Coastguard Worker break; 649*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: 650*58b9f456SAndroid Build Coastguard Worker case ios_base::in | ios_base::app | ios_base::binary: 651*58b9f456SAndroid Build Coastguard Worker __mdstr = L"a+b"; 652*58b9f456SAndroid Build Coastguard Worker break; 653*58b9f456SAndroid Build Coastguard Worker default: 654*58b9f456SAndroid Build Coastguard Worker __rt = 0; 655*58b9f456SAndroid Build Coastguard Worker break; 656*58b9f456SAndroid Build Coastguard Worker } 657*58b9f456SAndroid Build Coastguard Worker if (__rt) 658*58b9f456SAndroid Build Coastguard Worker { 659*58b9f456SAndroid Build Coastguard Worker __file_ = _wfopen(__s, __mdstr); 660*58b9f456SAndroid Build Coastguard Worker if (__file_) 661*58b9f456SAndroid Build Coastguard Worker { 662*58b9f456SAndroid Build Coastguard Worker __om_ = __mode; 663*58b9f456SAndroid Build Coastguard Worker if (__mode & ios_base::ate) 664*58b9f456SAndroid Build Coastguard Worker { 665*58b9f456SAndroid Build Coastguard Worker if (fseek(__file_, 0, SEEK_END)) 666*58b9f456SAndroid Build Coastguard Worker { 667*58b9f456SAndroid Build Coastguard Worker fclose(__file_); 668*58b9f456SAndroid Build Coastguard Worker __file_ = 0; 669*58b9f456SAndroid Build Coastguard Worker __rt = 0; 670*58b9f456SAndroid Build Coastguard Worker } 671*58b9f456SAndroid Build Coastguard Worker } 672*58b9f456SAndroid Build Coastguard Worker } 673*58b9f456SAndroid Build Coastguard Worker else 674*58b9f456SAndroid Build Coastguard Worker __rt = 0; 675*58b9f456SAndroid Build Coastguard Worker } 676*58b9f456SAndroid Build Coastguard Worker } 677*58b9f456SAndroid Build Coastguard Worker return __rt; 678*58b9f456SAndroid Build Coastguard Worker} 679*58b9f456SAndroid Build Coastguard Worker#endif 680*58b9f456SAndroid Build Coastguard Worker 681*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 682*58b9f456SAndroid Build Coastguard Workerinline 683*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>* 684*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) 685*58b9f456SAndroid Build Coastguard Worker{ 686*58b9f456SAndroid Build Coastguard Worker return open(__s.c_str(), __mode); 687*58b9f456SAndroid Build Coastguard Worker} 688*58b9f456SAndroid Build Coastguard Worker#endif 689*58b9f456SAndroid Build Coastguard Worker 690*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 691*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>* 692*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::close() 693*58b9f456SAndroid Build Coastguard Worker{ 694*58b9f456SAndroid Build Coastguard Worker basic_filebuf<_CharT, _Traits>* __rt = 0; 695*58b9f456SAndroid Build Coastguard Worker if (__file_) 696*58b9f456SAndroid Build Coastguard Worker { 697*58b9f456SAndroid Build Coastguard Worker __rt = this; 698*58b9f456SAndroid Build Coastguard Worker unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose); 699*58b9f456SAndroid Build Coastguard Worker if (sync()) 700*58b9f456SAndroid Build Coastguard Worker __rt = 0; 701*58b9f456SAndroid Build Coastguard Worker if (fclose(__h.release()) == 0) 702*58b9f456SAndroid Build Coastguard Worker __file_ = 0; 703*58b9f456SAndroid Build Coastguard Worker else 704*58b9f456SAndroid Build Coastguard Worker __rt = 0; 705*58b9f456SAndroid Build Coastguard Worker setbuf(0, 0); 706*58b9f456SAndroid Build Coastguard Worker } 707*58b9f456SAndroid Build Coastguard Worker return __rt; 708*58b9f456SAndroid Build Coastguard Worker} 709*58b9f456SAndroid Build Coastguard Worker 710*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 711*58b9f456SAndroid Build Coastguard Workertypename basic_filebuf<_CharT, _Traits>::int_type 712*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::underflow() 713*58b9f456SAndroid Build Coastguard Worker{ 714*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0) 715*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 716*58b9f456SAndroid Build Coastguard Worker bool __initial = __read_mode(); 717*58b9f456SAndroid Build Coastguard Worker char_type __1buf; 718*58b9f456SAndroid Build Coastguard Worker if (this->gptr() == 0) 719*58b9f456SAndroid Build Coastguard Worker this->setg(&__1buf, &__1buf+1, &__1buf+1); 720*58b9f456SAndroid Build Coastguard Worker const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4); 721*58b9f456SAndroid Build Coastguard Worker int_type __c = traits_type::eof(); 722*58b9f456SAndroid Build Coastguard Worker if (this->gptr() == this->egptr()) 723*58b9f456SAndroid Build Coastguard Worker { 724*58b9f456SAndroid Build Coastguard Worker memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); 725*58b9f456SAndroid Build Coastguard Worker if (__always_noconv_) 726*58b9f456SAndroid Build Coastguard Worker { 727*58b9f456SAndroid Build Coastguard Worker size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz); 728*58b9f456SAndroid Build Coastguard Worker __nmemb = fread(this->eback() + __unget_sz, 1, __nmemb, __file_); 729*58b9f456SAndroid Build Coastguard Worker if (__nmemb != 0) 730*58b9f456SAndroid Build Coastguard Worker { 731*58b9f456SAndroid Build Coastguard Worker this->setg(this->eback(), 732*58b9f456SAndroid Build Coastguard Worker this->eback() + __unget_sz, 733*58b9f456SAndroid Build Coastguard Worker this->eback() + __unget_sz + __nmemb); 734*58b9f456SAndroid Build Coastguard Worker __c = traits_type::to_int_type(*this->gptr()); 735*58b9f456SAndroid Build Coastguard Worker } 736*58b9f456SAndroid Build Coastguard Worker } 737*58b9f456SAndroid Build Coastguard Worker else 738*58b9f456SAndroid Build Coastguard Worker { 739*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" ); 740*58b9f456SAndroid Build Coastguard Worker if (__extbufend_ != __extbufnext_) 741*58b9f456SAndroid Build Coastguard Worker memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); 742*58b9f456SAndroid Build Coastguard Worker __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); 743*58b9f456SAndroid Build Coastguard Worker __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); 744*58b9f456SAndroid Build Coastguard Worker size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz), 745*58b9f456SAndroid Build Coastguard Worker static_cast<size_t>(__extbufend_ - __extbufnext_)); 746*58b9f456SAndroid Build Coastguard Worker codecvt_base::result __r; 747*58b9f456SAndroid Build Coastguard Worker __st_last_ = __st_; 748*58b9f456SAndroid Build Coastguard Worker size_t __nr = fread((void*) const_cast<char *>(__extbufnext_), 1, __nmemb, __file_); 749*58b9f456SAndroid Build Coastguard Worker if (__nr != 0) 750*58b9f456SAndroid Build Coastguard Worker { 751*58b9f456SAndroid Build Coastguard Worker if (!__cv_) 752*58b9f456SAndroid Build Coastguard Worker __throw_bad_cast(); 753*58b9f456SAndroid Build Coastguard Worker 754*58b9f456SAndroid Build Coastguard Worker __extbufend_ = __extbufnext_ + __nr; 755*58b9f456SAndroid Build Coastguard Worker char_type* __inext; 756*58b9f456SAndroid Build Coastguard Worker __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_, 757*58b9f456SAndroid Build Coastguard Worker this->eback() + __unget_sz, 758*58b9f456SAndroid Build Coastguard Worker this->eback() + __ibs_, __inext); 759*58b9f456SAndroid Build Coastguard Worker if (__r == codecvt_base::noconv) 760*58b9f456SAndroid Build Coastguard Worker { 761*58b9f456SAndroid Build Coastguard Worker this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, 762*58b9f456SAndroid Build Coastguard Worker (char_type*)const_cast<char *>(__extbufend_)); 763*58b9f456SAndroid Build Coastguard Worker __c = traits_type::to_int_type(*this->gptr()); 764*58b9f456SAndroid Build Coastguard Worker } 765*58b9f456SAndroid Build Coastguard Worker else if (__inext != this->eback() + __unget_sz) 766*58b9f456SAndroid Build Coastguard Worker { 767*58b9f456SAndroid Build Coastguard Worker this->setg(this->eback(), this->eback() + __unget_sz, __inext); 768*58b9f456SAndroid Build Coastguard Worker __c = traits_type::to_int_type(*this->gptr()); 769*58b9f456SAndroid Build Coastguard Worker } 770*58b9f456SAndroid Build Coastguard Worker } 771*58b9f456SAndroid Build Coastguard Worker } 772*58b9f456SAndroid Build Coastguard Worker } 773*58b9f456SAndroid Build Coastguard Worker else 774*58b9f456SAndroid Build Coastguard Worker __c = traits_type::to_int_type(*this->gptr()); 775*58b9f456SAndroid Build Coastguard Worker if (this->eback() == &__1buf) 776*58b9f456SAndroid Build Coastguard Worker this->setg(0, 0, 0); 777*58b9f456SAndroid Build Coastguard Worker return __c; 778*58b9f456SAndroid Build Coastguard Worker} 779*58b9f456SAndroid Build Coastguard Worker 780*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 781*58b9f456SAndroid Build Coastguard Workertypename basic_filebuf<_CharT, _Traits>::int_type 782*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::pbackfail(int_type __c) 783*58b9f456SAndroid Build Coastguard Worker{ 784*58b9f456SAndroid Build Coastguard Worker if (__file_ && this->eback() < this->gptr()) 785*58b9f456SAndroid Build Coastguard Worker { 786*58b9f456SAndroid Build Coastguard Worker if (traits_type::eq_int_type(__c, traits_type::eof())) 787*58b9f456SAndroid Build Coastguard Worker { 788*58b9f456SAndroid Build Coastguard Worker this->gbump(-1); 789*58b9f456SAndroid Build Coastguard Worker return traits_type::not_eof(__c); 790*58b9f456SAndroid Build Coastguard Worker } 791*58b9f456SAndroid Build Coastguard Worker if ((__om_ & ios_base::out) || 792*58b9f456SAndroid Build Coastguard Worker traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) 793*58b9f456SAndroid Build Coastguard Worker { 794*58b9f456SAndroid Build Coastguard Worker this->gbump(-1); 795*58b9f456SAndroid Build Coastguard Worker *this->gptr() = traits_type::to_char_type(__c); 796*58b9f456SAndroid Build Coastguard Worker return __c; 797*58b9f456SAndroid Build Coastguard Worker } 798*58b9f456SAndroid Build Coastguard Worker } 799*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 800*58b9f456SAndroid Build Coastguard Worker} 801*58b9f456SAndroid Build Coastguard Worker 802*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 803*58b9f456SAndroid Build Coastguard Workertypename basic_filebuf<_CharT, _Traits>::int_type 804*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::overflow(int_type __c) 805*58b9f456SAndroid Build Coastguard Worker{ 806*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0) 807*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 808*58b9f456SAndroid Build Coastguard Worker __write_mode(); 809*58b9f456SAndroid Build Coastguard Worker char_type __1buf; 810*58b9f456SAndroid Build Coastguard Worker char_type* __pb_save = this->pbase(); 811*58b9f456SAndroid Build Coastguard Worker char_type* __epb_save = this->epptr(); 812*58b9f456SAndroid Build Coastguard Worker if (!traits_type::eq_int_type(__c, traits_type::eof())) 813*58b9f456SAndroid Build Coastguard Worker { 814*58b9f456SAndroid Build Coastguard Worker if (this->pptr() == 0) 815*58b9f456SAndroid Build Coastguard Worker this->setp(&__1buf, &__1buf+1); 816*58b9f456SAndroid Build Coastguard Worker *this->pptr() = traits_type::to_char_type(__c); 817*58b9f456SAndroid Build Coastguard Worker this->pbump(1); 818*58b9f456SAndroid Build Coastguard Worker } 819*58b9f456SAndroid Build Coastguard Worker if (this->pptr() != this->pbase()) 820*58b9f456SAndroid Build Coastguard Worker { 821*58b9f456SAndroid Build Coastguard Worker if (__always_noconv_) 822*58b9f456SAndroid Build Coastguard Worker { 823*58b9f456SAndroid Build Coastguard Worker size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase()); 824*58b9f456SAndroid Build Coastguard Worker if (fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb) 825*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 826*58b9f456SAndroid Build Coastguard Worker } 827*58b9f456SAndroid Build Coastguard Worker else 828*58b9f456SAndroid Build Coastguard Worker { 829*58b9f456SAndroid Build Coastguard Worker char* __extbe = __extbuf_; 830*58b9f456SAndroid Build Coastguard Worker codecvt_base::result __r; 831*58b9f456SAndroid Build Coastguard Worker do 832*58b9f456SAndroid Build Coastguard Worker { 833*58b9f456SAndroid Build Coastguard Worker if (!__cv_) 834*58b9f456SAndroid Build Coastguard Worker __throw_bad_cast(); 835*58b9f456SAndroid Build Coastguard Worker 836*58b9f456SAndroid Build Coastguard Worker const char_type* __e; 837*58b9f456SAndroid Build Coastguard Worker __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, 838*58b9f456SAndroid Build Coastguard Worker __extbuf_, __extbuf_ + __ebs_, __extbe); 839*58b9f456SAndroid Build Coastguard Worker if (__e == this->pbase()) 840*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 841*58b9f456SAndroid Build Coastguard Worker if (__r == codecvt_base::noconv) 842*58b9f456SAndroid Build Coastguard Worker { 843*58b9f456SAndroid Build Coastguard Worker size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase()); 844*58b9f456SAndroid Build Coastguard Worker if (fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb) 845*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 846*58b9f456SAndroid Build Coastguard Worker } 847*58b9f456SAndroid Build Coastguard Worker else if (__r == codecvt_base::ok || __r == codecvt_base::partial) 848*58b9f456SAndroid Build Coastguard Worker { 849*58b9f456SAndroid Build Coastguard Worker size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_); 850*58b9f456SAndroid Build Coastguard Worker if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb) 851*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 852*58b9f456SAndroid Build Coastguard Worker if (__r == codecvt_base::partial) 853*58b9f456SAndroid Build Coastguard Worker { 854*58b9f456SAndroid Build Coastguard Worker this->setp(const_cast<char_type*>(__e), this->pptr()); 855*58b9f456SAndroid Build Coastguard Worker this->__pbump(this->epptr() - this->pbase()); 856*58b9f456SAndroid Build Coastguard Worker } 857*58b9f456SAndroid Build Coastguard Worker } 858*58b9f456SAndroid Build Coastguard Worker else 859*58b9f456SAndroid Build Coastguard Worker return traits_type::eof(); 860*58b9f456SAndroid Build Coastguard Worker } while (__r == codecvt_base::partial); 861*58b9f456SAndroid Build Coastguard Worker } 862*58b9f456SAndroid Build Coastguard Worker this->setp(__pb_save, __epb_save); 863*58b9f456SAndroid Build Coastguard Worker } 864*58b9f456SAndroid Build Coastguard Worker return traits_type::not_eof(__c); 865*58b9f456SAndroid Build Coastguard Worker} 866*58b9f456SAndroid Build Coastguard Worker 867*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 868*58b9f456SAndroid Build Coastguard Workerbasic_streambuf<_CharT, _Traits>* 869*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n) 870*58b9f456SAndroid Build Coastguard Worker{ 871*58b9f456SAndroid Build Coastguard Worker this->setg(0, 0, 0); 872*58b9f456SAndroid Build Coastguard Worker this->setp(0, 0); 873*58b9f456SAndroid Build Coastguard Worker if (__owns_eb_) 874*58b9f456SAndroid Build Coastguard Worker delete [] __extbuf_; 875*58b9f456SAndroid Build Coastguard Worker if (__owns_ib_) 876*58b9f456SAndroid Build Coastguard Worker delete [] __intbuf_; 877*58b9f456SAndroid Build Coastguard Worker __ebs_ = __n; 878*58b9f456SAndroid Build Coastguard Worker if (__ebs_ > sizeof(__extbuf_min_)) 879*58b9f456SAndroid Build Coastguard Worker { 880*58b9f456SAndroid Build Coastguard Worker if (__always_noconv_ && __s) 881*58b9f456SAndroid Build Coastguard Worker { 882*58b9f456SAndroid Build Coastguard Worker __extbuf_ = (char*)__s; 883*58b9f456SAndroid Build Coastguard Worker __owns_eb_ = false; 884*58b9f456SAndroid Build Coastguard Worker } 885*58b9f456SAndroid Build Coastguard Worker else 886*58b9f456SAndroid Build Coastguard Worker { 887*58b9f456SAndroid Build Coastguard Worker __extbuf_ = new char[__ebs_]; 888*58b9f456SAndroid Build Coastguard Worker __owns_eb_ = true; 889*58b9f456SAndroid Build Coastguard Worker } 890*58b9f456SAndroid Build Coastguard Worker } 891*58b9f456SAndroid Build Coastguard Worker else 892*58b9f456SAndroid Build Coastguard Worker { 893*58b9f456SAndroid Build Coastguard Worker __extbuf_ = __extbuf_min_; 894*58b9f456SAndroid Build Coastguard Worker __ebs_ = sizeof(__extbuf_min_); 895*58b9f456SAndroid Build Coastguard Worker __owns_eb_ = false; 896*58b9f456SAndroid Build Coastguard Worker } 897*58b9f456SAndroid Build Coastguard Worker if (!__always_noconv_) 898*58b9f456SAndroid Build Coastguard Worker { 899*58b9f456SAndroid Build Coastguard Worker __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_)); 900*58b9f456SAndroid Build Coastguard Worker if (__s && __ibs_ >= sizeof(__extbuf_min_)) 901*58b9f456SAndroid Build Coastguard Worker { 902*58b9f456SAndroid Build Coastguard Worker __intbuf_ = __s; 903*58b9f456SAndroid Build Coastguard Worker __owns_ib_ = false; 904*58b9f456SAndroid Build Coastguard Worker } 905*58b9f456SAndroid Build Coastguard Worker else 906*58b9f456SAndroid Build Coastguard Worker { 907*58b9f456SAndroid Build Coastguard Worker __intbuf_ = new char_type[__ibs_]; 908*58b9f456SAndroid Build Coastguard Worker __owns_ib_ = true; 909*58b9f456SAndroid Build Coastguard Worker } 910*58b9f456SAndroid Build Coastguard Worker } 911*58b9f456SAndroid Build Coastguard Worker else 912*58b9f456SAndroid Build Coastguard Worker { 913*58b9f456SAndroid Build Coastguard Worker __ibs_ = 0; 914*58b9f456SAndroid Build Coastguard Worker __intbuf_ = 0; 915*58b9f456SAndroid Build Coastguard Worker __owns_ib_ = false; 916*58b9f456SAndroid Build Coastguard Worker } 917*58b9f456SAndroid Build Coastguard Worker return this; 918*58b9f456SAndroid Build Coastguard Worker} 919*58b9f456SAndroid Build Coastguard Worker 920*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 921*58b9f456SAndroid Build Coastguard Workertypename basic_filebuf<_CharT, _Traits>::pos_type 922*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, 923*58b9f456SAndroid Build Coastguard Worker ios_base::openmode) 924*58b9f456SAndroid Build Coastguard Worker{ 925*58b9f456SAndroid Build Coastguard Worker if (!__cv_) 926*58b9f456SAndroid Build Coastguard Worker __throw_bad_cast(); 927*58b9f456SAndroid Build Coastguard Worker 928*58b9f456SAndroid Build Coastguard Worker int __width = __cv_->encoding(); 929*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0 || (__width <= 0 && __off != 0) || sync()) 930*58b9f456SAndroid Build Coastguard Worker return pos_type(off_type(-1)); 931*58b9f456SAndroid Build Coastguard Worker // __width > 0 || __off == 0 932*58b9f456SAndroid Build Coastguard Worker int __whence; 933*58b9f456SAndroid Build Coastguard Worker switch (__way) 934*58b9f456SAndroid Build Coastguard Worker { 935*58b9f456SAndroid Build Coastguard Worker case ios_base::beg: 936*58b9f456SAndroid Build Coastguard Worker __whence = SEEK_SET; 937*58b9f456SAndroid Build Coastguard Worker break; 938*58b9f456SAndroid Build Coastguard Worker case ios_base::cur: 939*58b9f456SAndroid Build Coastguard Worker __whence = SEEK_CUR; 940*58b9f456SAndroid Build Coastguard Worker break; 941*58b9f456SAndroid Build Coastguard Worker case ios_base::end: 942*58b9f456SAndroid Build Coastguard Worker __whence = SEEK_END; 943*58b9f456SAndroid Build Coastguard Worker break; 944*58b9f456SAndroid Build Coastguard Worker default: 945*58b9f456SAndroid Build Coastguard Worker return pos_type(off_type(-1)); 946*58b9f456SAndroid Build Coastguard Worker } 947*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) 948*58b9f456SAndroid Build Coastguard Worker if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) 949*58b9f456SAndroid Build Coastguard Worker return pos_type(off_type(-1)); 950*58b9f456SAndroid Build Coastguard Worker pos_type __r = ftell(__file_); 951*58b9f456SAndroid Build Coastguard Worker#else 952*58b9f456SAndroid Build Coastguard Worker if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence)) 953*58b9f456SAndroid Build Coastguard Worker return pos_type(off_type(-1)); 954*58b9f456SAndroid Build Coastguard Worker pos_type __r = ftello(__file_); 955*58b9f456SAndroid Build Coastguard Worker#endif 956*58b9f456SAndroid Build Coastguard Worker __r.state(__st_); 957*58b9f456SAndroid Build Coastguard Worker return __r; 958*58b9f456SAndroid Build Coastguard Worker} 959*58b9f456SAndroid Build Coastguard Worker 960*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 961*58b9f456SAndroid Build Coastguard Workertypename basic_filebuf<_CharT, _Traits>::pos_type 962*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) 963*58b9f456SAndroid Build Coastguard Worker{ 964*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0 || sync()) 965*58b9f456SAndroid Build Coastguard Worker return pos_type(off_type(-1)); 966*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) 967*58b9f456SAndroid Build Coastguard Worker if (fseek(__file_, __sp, SEEK_SET)) 968*58b9f456SAndroid Build Coastguard Worker return pos_type(off_type(-1)); 969*58b9f456SAndroid Build Coastguard Worker#else 970*58b9f456SAndroid Build Coastguard Worker if (fseeko(__file_, __sp, SEEK_SET)) 971*58b9f456SAndroid Build Coastguard Worker return pos_type(off_type(-1)); 972*58b9f456SAndroid Build Coastguard Worker#endif 973*58b9f456SAndroid Build Coastguard Worker __st_ = __sp.state(); 974*58b9f456SAndroid Build Coastguard Worker return __sp; 975*58b9f456SAndroid Build Coastguard Worker} 976*58b9f456SAndroid Build Coastguard Worker 977*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 978*58b9f456SAndroid Build Coastguard Workerint 979*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::sync() 980*58b9f456SAndroid Build Coastguard Worker{ 981*58b9f456SAndroid Build Coastguard Worker if (__file_ == 0) 982*58b9f456SAndroid Build Coastguard Worker return 0; 983*58b9f456SAndroid Build Coastguard Worker if (!__cv_) 984*58b9f456SAndroid Build Coastguard Worker __throw_bad_cast(); 985*58b9f456SAndroid Build Coastguard Worker 986*58b9f456SAndroid Build Coastguard Worker if (__cm_ & ios_base::out) 987*58b9f456SAndroid Build Coastguard Worker { 988*58b9f456SAndroid Build Coastguard Worker if (this->pptr() != this->pbase()) 989*58b9f456SAndroid Build Coastguard Worker if (overflow() == traits_type::eof()) 990*58b9f456SAndroid Build Coastguard Worker return -1; 991*58b9f456SAndroid Build Coastguard Worker codecvt_base::result __r; 992*58b9f456SAndroid Build Coastguard Worker do 993*58b9f456SAndroid Build Coastguard Worker { 994*58b9f456SAndroid Build Coastguard Worker char* __extbe; 995*58b9f456SAndroid Build Coastguard Worker __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe); 996*58b9f456SAndroid Build Coastguard Worker size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_); 997*58b9f456SAndroid Build Coastguard Worker if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb) 998*58b9f456SAndroid Build Coastguard Worker return -1; 999*58b9f456SAndroid Build Coastguard Worker } while (__r == codecvt_base::partial); 1000*58b9f456SAndroid Build Coastguard Worker if (__r == codecvt_base::error) 1001*58b9f456SAndroid Build Coastguard Worker return -1; 1002*58b9f456SAndroid Build Coastguard Worker if (fflush(__file_)) 1003*58b9f456SAndroid Build Coastguard Worker return -1; 1004*58b9f456SAndroid Build Coastguard Worker } 1005*58b9f456SAndroid Build Coastguard Worker else if (__cm_ & ios_base::in) 1006*58b9f456SAndroid Build Coastguard Worker { 1007*58b9f456SAndroid Build Coastguard Worker off_type __c; 1008*58b9f456SAndroid Build Coastguard Worker state_type __state = __st_last_; 1009*58b9f456SAndroid Build Coastguard Worker bool __update_st = false; 1010*58b9f456SAndroid Build Coastguard Worker if (__always_noconv_) 1011*58b9f456SAndroid Build Coastguard Worker __c = this->egptr() - this->gptr(); 1012*58b9f456SAndroid Build Coastguard Worker else 1013*58b9f456SAndroid Build Coastguard Worker { 1014*58b9f456SAndroid Build Coastguard Worker int __width = __cv_->encoding(); 1015*58b9f456SAndroid Build Coastguard Worker __c = __extbufend_ - __extbufnext_; 1016*58b9f456SAndroid Build Coastguard Worker if (__width > 0) 1017*58b9f456SAndroid Build Coastguard Worker __c += __width * (this->egptr() - this->gptr()); 1018*58b9f456SAndroid Build Coastguard Worker else 1019*58b9f456SAndroid Build Coastguard Worker { 1020*58b9f456SAndroid Build Coastguard Worker if (this->gptr() != this->egptr()) 1021*58b9f456SAndroid Build Coastguard Worker { 1022*58b9f456SAndroid Build Coastguard Worker const int __off = __cv_->length(__state, __extbuf_, 1023*58b9f456SAndroid Build Coastguard Worker __extbufnext_, 1024*58b9f456SAndroid Build Coastguard Worker this->gptr() - this->eback()); 1025*58b9f456SAndroid Build Coastguard Worker __c += __extbufnext_ - __extbuf_ - __off; 1026*58b9f456SAndroid Build Coastguard Worker __update_st = true; 1027*58b9f456SAndroid Build Coastguard Worker } 1028*58b9f456SAndroid Build Coastguard Worker } 1029*58b9f456SAndroid Build Coastguard Worker } 1030*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) 1031*58b9f456SAndroid Build Coastguard Worker if (fseek(__file_, -__c, SEEK_CUR)) 1032*58b9f456SAndroid Build Coastguard Worker return -1; 1033*58b9f456SAndroid Build Coastguard Worker#else 1034*58b9f456SAndroid Build Coastguard Worker if (fseeko(__file_, -__c, SEEK_CUR)) 1035*58b9f456SAndroid Build Coastguard Worker return -1; 1036*58b9f456SAndroid Build Coastguard Worker#endif 1037*58b9f456SAndroid Build Coastguard Worker if (__update_st) 1038*58b9f456SAndroid Build Coastguard Worker __st_ = __state; 1039*58b9f456SAndroid Build Coastguard Worker __extbufnext_ = __extbufend_ = __extbuf_; 1040*58b9f456SAndroid Build Coastguard Worker this->setg(0, 0, 0); 1041*58b9f456SAndroid Build Coastguard Worker __cm_ = 0; 1042*58b9f456SAndroid Build Coastguard Worker } 1043*58b9f456SAndroid Build Coastguard Worker return 0; 1044*58b9f456SAndroid Build Coastguard Worker} 1045*58b9f456SAndroid Build Coastguard Worker 1046*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1047*58b9f456SAndroid Build Coastguard Workervoid 1048*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) 1049*58b9f456SAndroid Build Coastguard Worker{ 1050*58b9f456SAndroid Build Coastguard Worker sync(); 1051*58b9f456SAndroid Build Coastguard Worker __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc); 1052*58b9f456SAndroid Build Coastguard Worker bool __old_anc = __always_noconv_; 1053*58b9f456SAndroid Build Coastguard Worker __always_noconv_ = __cv_->always_noconv(); 1054*58b9f456SAndroid Build Coastguard Worker if (__old_anc != __always_noconv_) 1055*58b9f456SAndroid Build Coastguard Worker { 1056*58b9f456SAndroid Build Coastguard Worker this->setg(0, 0, 0); 1057*58b9f456SAndroid Build Coastguard Worker this->setp(0, 0); 1058*58b9f456SAndroid Build Coastguard Worker // invariant, char_type is char, else we couldn't get here 1059*58b9f456SAndroid Build Coastguard Worker if (__always_noconv_) // need to dump __intbuf_ 1060*58b9f456SAndroid Build Coastguard Worker { 1061*58b9f456SAndroid Build Coastguard Worker if (__owns_eb_) 1062*58b9f456SAndroid Build Coastguard Worker delete [] __extbuf_; 1063*58b9f456SAndroid Build Coastguard Worker __owns_eb_ = __owns_ib_; 1064*58b9f456SAndroid Build Coastguard Worker __ebs_ = __ibs_; 1065*58b9f456SAndroid Build Coastguard Worker __extbuf_ = (char*)__intbuf_; 1066*58b9f456SAndroid Build Coastguard Worker __ibs_ = 0; 1067*58b9f456SAndroid Build Coastguard Worker __intbuf_ = 0; 1068*58b9f456SAndroid Build Coastguard Worker __owns_ib_ = false; 1069*58b9f456SAndroid Build Coastguard Worker } 1070*58b9f456SAndroid Build Coastguard Worker else // need to obtain an __intbuf_. 1071*58b9f456SAndroid Build Coastguard Worker { // If __extbuf_ is user-supplied, use it, else new __intbuf_ 1072*58b9f456SAndroid Build Coastguard Worker if (!__owns_eb_ && __extbuf_ != __extbuf_min_) 1073*58b9f456SAndroid Build Coastguard Worker { 1074*58b9f456SAndroid Build Coastguard Worker __ibs_ = __ebs_; 1075*58b9f456SAndroid Build Coastguard Worker __intbuf_ = (char_type*)__extbuf_; 1076*58b9f456SAndroid Build Coastguard Worker __owns_ib_ = false; 1077*58b9f456SAndroid Build Coastguard Worker __extbuf_ = new char[__ebs_]; 1078*58b9f456SAndroid Build Coastguard Worker __owns_eb_ = true; 1079*58b9f456SAndroid Build Coastguard Worker } 1080*58b9f456SAndroid Build Coastguard Worker else 1081*58b9f456SAndroid Build Coastguard Worker { 1082*58b9f456SAndroid Build Coastguard Worker __ibs_ = __ebs_; 1083*58b9f456SAndroid Build Coastguard Worker __intbuf_ = new char_type[__ibs_]; 1084*58b9f456SAndroid Build Coastguard Worker __owns_ib_ = true; 1085*58b9f456SAndroid Build Coastguard Worker } 1086*58b9f456SAndroid Build Coastguard Worker } 1087*58b9f456SAndroid Build Coastguard Worker } 1088*58b9f456SAndroid Build Coastguard Worker} 1089*58b9f456SAndroid Build Coastguard Worker 1090*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1091*58b9f456SAndroid Build Coastguard Workerbool 1092*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::__read_mode() 1093*58b9f456SAndroid Build Coastguard Worker{ 1094*58b9f456SAndroid Build Coastguard Worker if (!(__cm_ & ios_base::in)) 1095*58b9f456SAndroid Build Coastguard Worker { 1096*58b9f456SAndroid Build Coastguard Worker this->setp(0, 0); 1097*58b9f456SAndroid Build Coastguard Worker if (__always_noconv_) 1098*58b9f456SAndroid Build Coastguard Worker this->setg((char_type*)__extbuf_, 1099*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_ + __ebs_, 1100*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_ + __ebs_); 1101*58b9f456SAndroid Build Coastguard Worker else 1102*58b9f456SAndroid Build Coastguard Worker this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_); 1103*58b9f456SAndroid Build Coastguard Worker __cm_ = ios_base::in; 1104*58b9f456SAndroid Build Coastguard Worker return true; 1105*58b9f456SAndroid Build Coastguard Worker } 1106*58b9f456SAndroid Build Coastguard Worker return false; 1107*58b9f456SAndroid Build Coastguard Worker} 1108*58b9f456SAndroid Build Coastguard Worker 1109*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1110*58b9f456SAndroid Build Coastguard Workervoid 1111*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>::__write_mode() 1112*58b9f456SAndroid Build Coastguard Worker{ 1113*58b9f456SAndroid Build Coastguard Worker if (!(__cm_ & ios_base::out)) 1114*58b9f456SAndroid Build Coastguard Worker { 1115*58b9f456SAndroid Build Coastguard Worker this->setg(0, 0, 0); 1116*58b9f456SAndroid Build Coastguard Worker if (__ebs_ > sizeof(__extbuf_min_)) 1117*58b9f456SAndroid Build Coastguard Worker { 1118*58b9f456SAndroid Build Coastguard Worker if (__always_noconv_) 1119*58b9f456SAndroid Build Coastguard Worker this->setp((char_type*)__extbuf_, 1120*58b9f456SAndroid Build Coastguard Worker (char_type*)__extbuf_ + (__ebs_ - 1)); 1121*58b9f456SAndroid Build Coastguard Worker else 1122*58b9f456SAndroid Build Coastguard Worker this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1)); 1123*58b9f456SAndroid Build Coastguard Worker } 1124*58b9f456SAndroid Build Coastguard Worker else 1125*58b9f456SAndroid Build Coastguard Worker this->setp(0, 0); 1126*58b9f456SAndroid Build Coastguard Worker __cm_ = ios_base::out; 1127*58b9f456SAndroid Build Coastguard Worker } 1128*58b9f456SAndroid Build Coastguard Worker} 1129*58b9f456SAndroid Build Coastguard Worker 1130*58b9f456SAndroid Build Coastguard Worker// basic_ifstream 1131*58b9f456SAndroid Build Coastguard Worker 1132*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1133*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_ifstream 1134*58b9f456SAndroid Build Coastguard Worker : public basic_istream<_CharT, _Traits> 1135*58b9f456SAndroid Build Coastguard Worker{ 1136*58b9f456SAndroid Build Coastguard Workerpublic: 1137*58b9f456SAndroid Build Coastguard Worker typedef _CharT char_type; 1138*58b9f456SAndroid Build Coastguard Worker typedef _Traits traits_type; 1139*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 1140*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 1141*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 1142*58b9f456SAndroid Build Coastguard Worker 1143*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1144*58b9f456SAndroid Build Coastguard Worker basic_ifstream(); 1145*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1146*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1147*58b9f456SAndroid Build Coastguard Worker explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in); 1148*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1149*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1150*58b9f456SAndroid Build Coastguard Worker explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); 1151*58b9f456SAndroid Build Coastguard Worker#endif 1152*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1153*58b9f456SAndroid Build Coastguard Worker explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); 1154*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 17 1155*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1156*58b9f456SAndroid Build Coastguard Worker explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) 1157*58b9f456SAndroid Build Coastguard Worker : basic_ifstream(__p.c_str(), __mode) {} 1158*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER >= 17 1159*58b9f456SAndroid Build Coastguard Worker#endif 1160*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1161*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1162*58b9f456SAndroid Build Coastguard Worker basic_ifstream(basic_ifstream&& __rhs); 1163*58b9f456SAndroid Build Coastguard Worker 1164*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1165*58b9f456SAndroid Build Coastguard Worker basic_ifstream& operator=(basic_ifstream&& __rhs); 1166*58b9f456SAndroid Build Coastguard Worker#endif 1167*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1168*58b9f456SAndroid Build Coastguard Worker void swap(basic_ifstream& __rhs); 1169*58b9f456SAndroid Build Coastguard Worker 1170*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1171*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type>* rdbuf() const; 1172*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1173*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 1174*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1175*58b9f456SAndroid Build Coastguard Worker void open(const char* __s, ios_base::openmode __mode = ios_base::in); 1176*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1177*58b9f456SAndroid Build Coastguard Worker void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); 1178*58b9f456SAndroid Build Coastguard Worker#endif 1179*58b9f456SAndroid Build Coastguard Worker void open(const string& __s, ios_base::openmode __mode = ios_base::in); 1180*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 17 1181*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1182*58b9f456SAndroid Build Coastguard Worker void open(const filesystem::path& __p, 1183*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __mode = ios_base::in) { 1184*58b9f456SAndroid Build Coastguard Worker return open(__p.c_str(), __mode); 1185*58b9f456SAndroid Build Coastguard Worker } 1186*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER >= 17 1187*58b9f456SAndroid Build Coastguard Worker 1188*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1189*58b9f456SAndroid Build Coastguard Worker void __open(int __fd, ios_base::openmode __mode); 1190*58b9f456SAndroid Build Coastguard Worker#endif 1191*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1192*58b9f456SAndroid Build Coastguard Worker void close(); 1193*58b9f456SAndroid Build Coastguard Worker 1194*58b9f456SAndroid Build Coastguard Workerprivate: 1195*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type> __sb_; 1196*58b9f456SAndroid Build Coastguard Worker}; 1197*58b9f456SAndroid Build Coastguard Worker 1198*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1199*58b9f456SAndroid Build Coastguard Workerinline 1200*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::basic_ifstream() 1201*58b9f456SAndroid Build Coastguard Worker : basic_istream<char_type, traits_type>(&__sb_) 1202*58b9f456SAndroid Build Coastguard Worker{ 1203*58b9f456SAndroid Build Coastguard Worker} 1204*58b9f456SAndroid Build Coastguard Worker 1205*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1206*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1207*58b9f456SAndroid Build Coastguard Workerinline 1208*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode) 1209*58b9f456SAndroid Build Coastguard Worker : basic_istream<char_type, traits_type>(&__sb_) 1210*58b9f456SAndroid Build Coastguard Worker{ 1211*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::in) == 0) 1212*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1213*58b9f456SAndroid Build Coastguard Worker} 1214*58b9f456SAndroid Build Coastguard Worker 1215*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1216*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1217*58b9f456SAndroid Build Coastguard Workerinline 1218*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode) 1219*58b9f456SAndroid Build Coastguard Worker : basic_istream<char_type, traits_type>(&__sb_) 1220*58b9f456SAndroid Build Coastguard Worker{ 1221*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::in) == 0) 1222*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1223*58b9f456SAndroid Build Coastguard Worker} 1224*58b9f456SAndroid Build Coastguard Worker#endif 1225*58b9f456SAndroid Build Coastguard Worker 1226*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1227*58b9f456SAndroid Build Coastguard Workerinline 1228*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode) 1229*58b9f456SAndroid Build Coastguard Worker : basic_istream<char_type, traits_type>(&__sb_) 1230*58b9f456SAndroid Build Coastguard Worker{ 1231*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::in) == 0) 1232*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1233*58b9f456SAndroid Build Coastguard Worker} 1234*58b9f456SAndroid Build Coastguard Worker#endif 1235*58b9f456SAndroid Build Coastguard Worker 1236*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1237*58b9f456SAndroid Build Coastguard Worker 1238*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1239*58b9f456SAndroid Build Coastguard Workerinline 1240*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs) 1241*58b9f456SAndroid Build Coastguard Worker : basic_istream<char_type, traits_type>(_VSTD::move(__rhs)), 1242*58b9f456SAndroid Build Coastguard Worker __sb_(_VSTD::move(__rhs.__sb_)) 1243*58b9f456SAndroid Build Coastguard Worker{ 1244*58b9f456SAndroid Build Coastguard Worker this->set_rdbuf(&__sb_); 1245*58b9f456SAndroid Build Coastguard Worker} 1246*58b9f456SAndroid Build Coastguard Worker 1247*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1248*58b9f456SAndroid Build Coastguard Workerinline 1249*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>& 1250*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs) 1251*58b9f456SAndroid Build Coastguard Worker{ 1252*58b9f456SAndroid Build Coastguard Worker basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs)); 1253*58b9f456SAndroid Build Coastguard Worker __sb_ = _VSTD::move(__rhs.__sb_); 1254*58b9f456SAndroid Build Coastguard Worker return *this; 1255*58b9f456SAndroid Build Coastguard Worker} 1256*58b9f456SAndroid Build Coastguard Worker 1257*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG 1258*58b9f456SAndroid Build Coastguard Worker 1259*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1260*58b9f456SAndroid Build Coastguard Workerinline 1261*58b9f456SAndroid Build Coastguard Workervoid 1262*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::swap(basic_ifstream& __rhs) 1263*58b9f456SAndroid Build Coastguard Worker{ 1264*58b9f456SAndroid Build Coastguard Worker basic_istream<char_type, traits_type>::swap(__rhs); 1265*58b9f456SAndroid Build Coastguard Worker __sb_.swap(__rhs.__sb_); 1266*58b9f456SAndroid Build Coastguard Worker} 1267*58b9f456SAndroid Build Coastguard Worker 1268*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1269*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1270*58b9f456SAndroid Build Coastguard Workervoid 1271*58b9f456SAndroid Build Coastguard Workerswap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y) 1272*58b9f456SAndroid Build Coastguard Worker{ 1273*58b9f456SAndroid Build Coastguard Worker __x.swap(__y); 1274*58b9f456SAndroid Build Coastguard Worker} 1275*58b9f456SAndroid Build Coastguard Worker 1276*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1277*58b9f456SAndroid Build Coastguard Workerinline 1278*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>* 1279*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::rdbuf() const 1280*58b9f456SAndroid Build Coastguard Worker{ 1281*58b9f456SAndroid Build Coastguard Worker return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); 1282*58b9f456SAndroid Build Coastguard Worker} 1283*58b9f456SAndroid Build Coastguard Worker 1284*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1285*58b9f456SAndroid Build Coastguard Workerinline 1286*58b9f456SAndroid Build Coastguard Workerbool 1287*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::is_open() const 1288*58b9f456SAndroid Build Coastguard Worker{ 1289*58b9f456SAndroid Build Coastguard Worker return __sb_.is_open(); 1290*58b9f456SAndroid Build Coastguard Worker} 1291*58b9f456SAndroid Build Coastguard Worker 1292*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1293*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1294*58b9f456SAndroid Build Coastguard Workervoid 1295*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) 1296*58b9f456SAndroid Build Coastguard Worker{ 1297*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::in)) 1298*58b9f456SAndroid Build Coastguard Worker this->clear(); 1299*58b9f456SAndroid Build Coastguard Worker else 1300*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1301*58b9f456SAndroid Build Coastguard Worker} 1302*58b9f456SAndroid Build Coastguard Worker 1303*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1304*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1305*58b9f456SAndroid Build Coastguard Workervoid 1306*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) 1307*58b9f456SAndroid Build Coastguard Worker{ 1308*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::in)) 1309*58b9f456SAndroid Build Coastguard Worker this->clear(); 1310*58b9f456SAndroid Build Coastguard Worker else 1311*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1312*58b9f456SAndroid Build Coastguard Worker} 1313*58b9f456SAndroid Build Coastguard Worker#endif 1314*58b9f456SAndroid Build Coastguard Worker 1315*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1316*58b9f456SAndroid Build Coastguard Workervoid 1317*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) 1318*58b9f456SAndroid Build Coastguard Worker{ 1319*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::in)) 1320*58b9f456SAndroid Build Coastguard Worker this->clear(); 1321*58b9f456SAndroid Build Coastguard Worker else 1322*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1323*58b9f456SAndroid Build Coastguard Worker} 1324*58b9f456SAndroid Build Coastguard Worker 1325*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1326*58b9f456SAndroid Build Coastguard Workervoid basic_ifstream<_CharT, _Traits>::__open(int __fd, 1327*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __mode) { 1328*58b9f456SAndroid Build Coastguard Worker if (__sb_.__open(__fd, __mode | ios_base::in)) 1329*58b9f456SAndroid Build Coastguard Worker this->clear(); 1330*58b9f456SAndroid Build Coastguard Worker else 1331*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1332*58b9f456SAndroid Build Coastguard Worker} 1333*58b9f456SAndroid Build Coastguard Worker#endif 1334*58b9f456SAndroid Build Coastguard Worker 1335*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1336*58b9f456SAndroid Build Coastguard Workerinline 1337*58b9f456SAndroid Build Coastguard Workervoid 1338*58b9f456SAndroid Build Coastguard Workerbasic_ifstream<_CharT, _Traits>::close() 1339*58b9f456SAndroid Build Coastguard Worker{ 1340*58b9f456SAndroid Build Coastguard Worker if (__sb_.close() == 0) 1341*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1342*58b9f456SAndroid Build Coastguard Worker} 1343*58b9f456SAndroid Build Coastguard Worker 1344*58b9f456SAndroid Build Coastguard Worker// basic_ofstream 1345*58b9f456SAndroid Build Coastguard Worker 1346*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1347*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_ofstream 1348*58b9f456SAndroid Build Coastguard Worker : public basic_ostream<_CharT, _Traits> 1349*58b9f456SAndroid Build Coastguard Worker{ 1350*58b9f456SAndroid Build Coastguard Workerpublic: 1351*58b9f456SAndroid Build Coastguard Worker typedef _CharT char_type; 1352*58b9f456SAndroid Build Coastguard Worker typedef _Traits traits_type; 1353*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 1354*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 1355*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 1356*58b9f456SAndroid Build Coastguard Worker 1357*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1358*58b9f456SAndroid Build Coastguard Worker basic_ofstream(); 1359*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1360*58b9f456SAndroid Build Coastguard Worker explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out); 1361*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1362*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1363*58b9f456SAndroid Build Coastguard Worker explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); 1364*58b9f456SAndroid Build Coastguard Worker#endif 1365*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1366*58b9f456SAndroid Build Coastguard Worker explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out); 1367*58b9f456SAndroid Build Coastguard Worker 1368*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 17 1369*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1370*58b9f456SAndroid Build Coastguard Worker explicit basic_ofstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) 1371*58b9f456SAndroid Build Coastguard Worker : basic_ofstream(__p.c_str(), __mode) {} 1372*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER >= 17 1373*58b9f456SAndroid Build Coastguard Worker 1374*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1375*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1376*58b9f456SAndroid Build Coastguard Worker basic_ofstream(basic_ofstream&& __rhs); 1377*58b9f456SAndroid Build Coastguard Worker 1378*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1379*58b9f456SAndroid Build Coastguard Worker basic_ofstream& operator=(basic_ofstream&& __rhs); 1380*58b9f456SAndroid Build Coastguard Worker#endif 1381*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1382*58b9f456SAndroid Build Coastguard Worker void swap(basic_ofstream& __rhs); 1383*58b9f456SAndroid Build Coastguard Worker 1384*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1385*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type>* rdbuf() const; 1386*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1387*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 1388*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1389*58b9f456SAndroid Build Coastguard Worker void open(const char* __s, ios_base::openmode __mode = ios_base::out); 1390*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1391*58b9f456SAndroid Build Coastguard Worker void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); 1392*58b9f456SAndroid Build Coastguard Worker#endif 1393*58b9f456SAndroid Build Coastguard Worker void open(const string& __s, ios_base::openmode __mode = ios_base::out); 1394*58b9f456SAndroid Build Coastguard Worker 1395*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 17 1396*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1397*58b9f456SAndroid Build Coastguard Worker void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) 1398*58b9f456SAndroid Build Coastguard Worker { return open(__p.c_str(), __mode); } 1399*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER >= 17 1400*58b9f456SAndroid Build Coastguard Worker 1401*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1402*58b9f456SAndroid Build Coastguard Worker void __open(int __fd, ios_base::openmode __mode); 1403*58b9f456SAndroid Build Coastguard Worker#endif 1404*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1405*58b9f456SAndroid Build Coastguard Worker void close(); 1406*58b9f456SAndroid Build Coastguard Worker 1407*58b9f456SAndroid Build Coastguard Workerprivate: 1408*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type> __sb_; 1409*58b9f456SAndroid Build Coastguard Worker}; 1410*58b9f456SAndroid Build Coastguard Worker 1411*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1412*58b9f456SAndroid Build Coastguard Workerinline 1413*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::basic_ofstream() 1414*58b9f456SAndroid Build Coastguard Worker : basic_ostream<char_type, traits_type>(&__sb_) 1415*58b9f456SAndroid Build Coastguard Worker{ 1416*58b9f456SAndroid Build Coastguard Worker} 1417*58b9f456SAndroid Build Coastguard Worker 1418*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1419*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1420*58b9f456SAndroid Build Coastguard Workerinline 1421*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode) 1422*58b9f456SAndroid Build Coastguard Worker : basic_ostream<char_type, traits_type>(&__sb_) 1423*58b9f456SAndroid Build Coastguard Worker{ 1424*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::out) == 0) 1425*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1426*58b9f456SAndroid Build Coastguard Worker} 1427*58b9f456SAndroid Build Coastguard Worker 1428*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1429*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1430*58b9f456SAndroid Build Coastguard Workerinline 1431*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode) 1432*58b9f456SAndroid Build Coastguard Worker : basic_ostream<char_type, traits_type>(&__sb_) 1433*58b9f456SAndroid Build Coastguard Worker{ 1434*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::out) == 0) 1435*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1436*58b9f456SAndroid Build Coastguard Worker} 1437*58b9f456SAndroid Build Coastguard Worker#endif 1438*58b9f456SAndroid Build Coastguard Worker 1439*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1440*58b9f456SAndroid Build Coastguard Workerinline 1441*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode) 1442*58b9f456SAndroid Build Coastguard Worker : basic_ostream<char_type, traits_type>(&__sb_) 1443*58b9f456SAndroid Build Coastguard Worker{ 1444*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::out) == 0) 1445*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1446*58b9f456SAndroid Build Coastguard Worker} 1447*58b9f456SAndroid Build Coastguard Worker#endif 1448*58b9f456SAndroid Build Coastguard Worker 1449*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1450*58b9f456SAndroid Build Coastguard Worker 1451*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1452*58b9f456SAndroid Build Coastguard Workerinline 1453*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs) 1454*58b9f456SAndroid Build Coastguard Worker : basic_ostream<char_type, traits_type>(_VSTD::move(__rhs)), 1455*58b9f456SAndroid Build Coastguard Worker __sb_(_VSTD::move(__rhs.__sb_)) 1456*58b9f456SAndroid Build Coastguard Worker{ 1457*58b9f456SAndroid Build Coastguard Worker this->set_rdbuf(&__sb_); 1458*58b9f456SAndroid Build Coastguard Worker} 1459*58b9f456SAndroid Build Coastguard Worker 1460*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1461*58b9f456SAndroid Build Coastguard Workerinline 1462*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>& 1463*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs) 1464*58b9f456SAndroid Build Coastguard Worker{ 1465*58b9f456SAndroid Build Coastguard Worker basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs)); 1466*58b9f456SAndroid Build Coastguard Worker __sb_ = _VSTD::move(__rhs.__sb_); 1467*58b9f456SAndroid Build Coastguard Worker return *this; 1468*58b9f456SAndroid Build Coastguard Worker} 1469*58b9f456SAndroid Build Coastguard Worker 1470*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG 1471*58b9f456SAndroid Build Coastguard Worker 1472*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1473*58b9f456SAndroid Build Coastguard Workerinline 1474*58b9f456SAndroid Build Coastguard Workervoid 1475*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::swap(basic_ofstream& __rhs) 1476*58b9f456SAndroid Build Coastguard Worker{ 1477*58b9f456SAndroid Build Coastguard Worker basic_ostream<char_type, traits_type>::swap(__rhs); 1478*58b9f456SAndroid Build Coastguard Worker __sb_.swap(__rhs.__sb_); 1479*58b9f456SAndroid Build Coastguard Worker} 1480*58b9f456SAndroid Build Coastguard Worker 1481*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1482*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1483*58b9f456SAndroid Build Coastguard Workervoid 1484*58b9f456SAndroid Build Coastguard Workerswap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y) 1485*58b9f456SAndroid Build Coastguard Worker{ 1486*58b9f456SAndroid Build Coastguard Worker __x.swap(__y); 1487*58b9f456SAndroid Build Coastguard Worker} 1488*58b9f456SAndroid Build Coastguard Worker 1489*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1490*58b9f456SAndroid Build Coastguard Workerinline 1491*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>* 1492*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::rdbuf() const 1493*58b9f456SAndroid Build Coastguard Worker{ 1494*58b9f456SAndroid Build Coastguard Worker return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); 1495*58b9f456SAndroid Build Coastguard Worker} 1496*58b9f456SAndroid Build Coastguard Worker 1497*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1498*58b9f456SAndroid Build Coastguard Workerinline 1499*58b9f456SAndroid Build Coastguard Workerbool 1500*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::is_open() const 1501*58b9f456SAndroid Build Coastguard Worker{ 1502*58b9f456SAndroid Build Coastguard Worker return __sb_.is_open(); 1503*58b9f456SAndroid Build Coastguard Worker} 1504*58b9f456SAndroid Build Coastguard Worker 1505*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1506*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1507*58b9f456SAndroid Build Coastguard Workervoid 1508*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) 1509*58b9f456SAndroid Build Coastguard Worker{ 1510*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::out)) 1511*58b9f456SAndroid Build Coastguard Worker this->clear(); 1512*58b9f456SAndroid Build Coastguard Worker else 1513*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1514*58b9f456SAndroid Build Coastguard Worker} 1515*58b9f456SAndroid Build Coastguard Worker 1516*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1517*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1518*58b9f456SAndroid Build Coastguard Workervoid 1519*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) 1520*58b9f456SAndroid Build Coastguard Worker{ 1521*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::out)) 1522*58b9f456SAndroid Build Coastguard Worker this->clear(); 1523*58b9f456SAndroid Build Coastguard Worker else 1524*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1525*58b9f456SAndroid Build Coastguard Worker} 1526*58b9f456SAndroid Build Coastguard Worker#endif 1527*58b9f456SAndroid Build Coastguard Worker 1528*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1529*58b9f456SAndroid Build Coastguard Workervoid 1530*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) 1531*58b9f456SAndroid Build Coastguard Worker{ 1532*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode | ios_base::out)) 1533*58b9f456SAndroid Build Coastguard Worker this->clear(); 1534*58b9f456SAndroid Build Coastguard Worker else 1535*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1536*58b9f456SAndroid Build Coastguard Worker} 1537*58b9f456SAndroid Build Coastguard Worker 1538*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1539*58b9f456SAndroid Build Coastguard Workervoid basic_ofstream<_CharT, _Traits>::__open(int __fd, 1540*58b9f456SAndroid Build Coastguard Worker ios_base::openmode __mode) { 1541*58b9f456SAndroid Build Coastguard Worker if (__sb_.__open(__fd, __mode | ios_base::out)) 1542*58b9f456SAndroid Build Coastguard Worker this->clear(); 1543*58b9f456SAndroid Build Coastguard Worker else 1544*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1545*58b9f456SAndroid Build Coastguard Worker} 1546*58b9f456SAndroid Build Coastguard Worker#endif 1547*58b9f456SAndroid Build Coastguard Worker 1548*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1549*58b9f456SAndroid Build Coastguard Workerinline 1550*58b9f456SAndroid Build Coastguard Workervoid 1551*58b9f456SAndroid Build Coastguard Workerbasic_ofstream<_CharT, _Traits>::close() 1552*58b9f456SAndroid Build Coastguard Worker{ 1553*58b9f456SAndroid Build Coastguard Worker if (__sb_.close() == 0) 1554*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1555*58b9f456SAndroid Build Coastguard Worker} 1556*58b9f456SAndroid Build Coastguard Worker 1557*58b9f456SAndroid Build Coastguard Worker// basic_fstream 1558*58b9f456SAndroid Build Coastguard Worker 1559*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1560*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_fstream 1561*58b9f456SAndroid Build Coastguard Worker : public basic_iostream<_CharT, _Traits> 1562*58b9f456SAndroid Build Coastguard Worker{ 1563*58b9f456SAndroid Build Coastguard Workerpublic: 1564*58b9f456SAndroid Build Coastguard Worker typedef _CharT char_type; 1565*58b9f456SAndroid Build Coastguard Worker typedef _Traits traits_type; 1566*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::int_type int_type; 1567*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::pos_type pos_type; 1568*58b9f456SAndroid Build Coastguard Worker typedef typename traits_type::off_type off_type; 1569*58b9f456SAndroid Build Coastguard Worker 1570*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1571*58b9f456SAndroid Build Coastguard Worker basic_fstream(); 1572*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1573*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1574*58b9f456SAndroid Build Coastguard Worker explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); 1575*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1576*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1577*58b9f456SAndroid Build Coastguard Worker explicit basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); 1578*58b9f456SAndroid Build Coastguard Worker#endif 1579*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1580*58b9f456SAndroid Build Coastguard Worker explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); 1581*58b9f456SAndroid Build Coastguard Worker 1582*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 17 1583*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1584*58b9f456SAndroid Build Coastguard Worker explicit basic_fstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) 1585*58b9f456SAndroid Build Coastguard Worker : basic_fstream(__p.c_str(), __mode) {} 1586*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER >= 17 1587*58b9f456SAndroid Build Coastguard Worker 1588*58b9f456SAndroid Build Coastguard Worker#endif 1589*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1590*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1591*58b9f456SAndroid Build Coastguard Worker basic_fstream(basic_fstream&& __rhs); 1592*58b9f456SAndroid Build Coastguard Worker 1593*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1594*58b9f456SAndroid Build Coastguard Worker basic_fstream& operator=(basic_fstream&& __rhs); 1595*58b9f456SAndroid Build Coastguard Worker#endif 1596*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1597*58b9f456SAndroid Build Coastguard Worker void swap(basic_fstream& __rhs); 1598*58b9f456SAndroid Build Coastguard Worker 1599*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1600*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type>* rdbuf() const; 1601*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1602*58b9f456SAndroid Build Coastguard Worker bool is_open() const; 1603*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1604*58b9f456SAndroid Build Coastguard Worker void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); 1605*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1606*58b9f456SAndroid Build Coastguard Worker void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); 1607*58b9f456SAndroid Build Coastguard Worker#endif 1608*58b9f456SAndroid Build Coastguard Worker void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); 1609*58b9f456SAndroid Build Coastguard Worker 1610*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 17 1611*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1612*58b9f456SAndroid Build Coastguard Worker void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in|ios_base::out) 1613*58b9f456SAndroid Build Coastguard Worker { return open(__p.c_str(), __mode); } 1614*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER >= 17 1615*58b9f456SAndroid Build Coastguard Worker 1616*58b9f456SAndroid Build Coastguard Worker#endif 1617*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1618*58b9f456SAndroid Build Coastguard Worker void close(); 1619*58b9f456SAndroid Build Coastguard Worker 1620*58b9f456SAndroid Build Coastguard Workerprivate: 1621*58b9f456SAndroid Build Coastguard Worker basic_filebuf<char_type, traits_type> __sb_; 1622*58b9f456SAndroid Build Coastguard Worker}; 1623*58b9f456SAndroid Build Coastguard Worker 1624*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1625*58b9f456SAndroid Build Coastguard Workerinline 1626*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::basic_fstream() 1627*58b9f456SAndroid Build Coastguard Worker : basic_iostream<char_type, traits_type>(&__sb_) 1628*58b9f456SAndroid Build Coastguard Worker{ 1629*58b9f456SAndroid Build Coastguard Worker} 1630*58b9f456SAndroid Build Coastguard Worker 1631*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1632*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1633*58b9f456SAndroid Build Coastguard Workerinline 1634*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode) 1635*58b9f456SAndroid Build Coastguard Worker : basic_iostream<char_type, traits_type>(&__sb_) 1636*58b9f456SAndroid Build Coastguard Worker{ 1637*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode) == 0) 1638*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1639*58b9f456SAndroid Build Coastguard Worker} 1640*58b9f456SAndroid Build Coastguard Worker 1641*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1642*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1643*58b9f456SAndroid Build Coastguard Workerinline 1644*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode) 1645*58b9f456SAndroid Build Coastguard Worker : basic_iostream<char_type, traits_type>(&__sb_) 1646*58b9f456SAndroid Build Coastguard Worker{ 1647*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode) == 0) 1648*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1649*58b9f456SAndroid Build Coastguard Worker} 1650*58b9f456SAndroid Build Coastguard Worker#endif 1651*58b9f456SAndroid Build Coastguard Worker 1652*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1653*58b9f456SAndroid Build Coastguard Workerinline 1654*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode) 1655*58b9f456SAndroid Build Coastguard Worker : basic_iostream<char_type, traits_type>(&__sb_) 1656*58b9f456SAndroid Build Coastguard Worker{ 1657*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode) == 0) 1658*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1659*58b9f456SAndroid Build Coastguard Worker} 1660*58b9f456SAndroid Build Coastguard Worker#endif 1661*58b9f456SAndroid Build Coastguard Worker 1662*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 1663*58b9f456SAndroid Build Coastguard Worker 1664*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1665*58b9f456SAndroid Build Coastguard Workerinline 1666*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs) 1667*58b9f456SAndroid Build Coastguard Worker : basic_iostream<char_type, traits_type>(_VSTD::move(__rhs)), 1668*58b9f456SAndroid Build Coastguard Worker __sb_(_VSTD::move(__rhs.__sb_)) 1669*58b9f456SAndroid Build Coastguard Worker{ 1670*58b9f456SAndroid Build Coastguard Worker this->set_rdbuf(&__sb_); 1671*58b9f456SAndroid Build Coastguard Worker} 1672*58b9f456SAndroid Build Coastguard Worker 1673*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1674*58b9f456SAndroid Build Coastguard Workerinline 1675*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>& 1676*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs) 1677*58b9f456SAndroid Build Coastguard Worker{ 1678*58b9f456SAndroid Build Coastguard Worker basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs)); 1679*58b9f456SAndroid Build Coastguard Worker __sb_ = _VSTD::move(__rhs.__sb_); 1680*58b9f456SAndroid Build Coastguard Worker return *this; 1681*58b9f456SAndroid Build Coastguard Worker} 1682*58b9f456SAndroid Build Coastguard Worker 1683*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG 1684*58b9f456SAndroid Build Coastguard Worker 1685*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1686*58b9f456SAndroid Build Coastguard Workerinline 1687*58b9f456SAndroid Build Coastguard Workervoid 1688*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::swap(basic_fstream& __rhs) 1689*58b9f456SAndroid Build Coastguard Worker{ 1690*58b9f456SAndroid Build Coastguard Worker basic_iostream<char_type, traits_type>::swap(__rhs); 1691*58b9f456SAndroid Build Coastguard Worker __sb_.swap(__rhs.__sb_); 1692*58b9f456SAndroid Build Coastguard Worker} 1693*58b9f456SAndroid Build Coastguard Worker 1694*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1695*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1696*58b9f456SAndroid Build Coastguard Workervoid 1697*58b9f456SAndroid Build Coastguard Workerswap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y) 1698*58b9f456SAndroid Build Coastguard Worker{ 1699*58b9f456SAndroid Build Coastguard Worker __x.swap(__y); 1700*58b9f456SAndroid Build Coastguard Worker} 1701*58b9f456SAndroid Build Coastguard Worker 1702*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1703*58b9f456SAndroid Build Coastguard Workerinline 1704*58b9f456SAndroid Build Coastguard Workerbasic_filebuf<_CharT, _Traits>* 1705*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::rdbuf() const 1706*58b9f456SAndroid Build Coastguard Worker{ 1707*58b9f456SAndroid Build Coastguard Worker return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); 1708*58b9f456SAndroid Build Coastguard Worker} 1709*58b9f456SAndroid Build Coastguard Worker 1710*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1711*58b9f456SAndroid Build Coastguard Workerinline 1712*58b9f456SAndroid Build Coastguard Workerbool 1713*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::is_open() const 1714*58b9f456SAndroid Build Coastguard Worker{ 1715*58b9f456SAndroid Build Coastguard Worker return __sb_.is_open(); 1716*58b9f456SAndroid Build Coastguard Worker} 1717*58b9f456SAndroid Build Coastguard Worker 1718*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE 1719*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1720*58b9f456SAndroid Build Coastguard Workervoid 1721*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) 1722*58b9f456SAndroid Build Coastguard Worker{ 1723*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode)) 1724*58b9f456SAndroid Build Coastguard Worker this->clear(); 1725*58b9f456SAndroid Build Coastguard Worker else 1726*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1727*58b9f456SAndroid Build Coastguard Worker} 1728*58b9f456SAndroid Build Coastguard Worker 1729*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR 1730*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1731*58b9f456SAndroid Build Coastguard Workervoid 1732*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) 1733*58b9f456SAndroid Build Coastguard Worker{ 1734*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode)) 1735*58b9f456SAndroid Build Coastguard Worker this->clear(); 1736*58b9f456SAndroid Build Coastguard Worker else 1737*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1738*58b9f456SAndroid Build Coastguard Worker} 1739*58b9f456SAndroid Build Coastguard Worker#endif 1740*58b9f456SAndroid Build Coastguard Worker 1741*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1742*58b9f456SAndroid Build Coastguard Workervoid 1743*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) 1744*58b9f456SAndroid Build Coastguard Worker{ 1745*58b9f456SAndroid Build Coastguard Worker if (__sb_.open(__s, __mode)) 1746*58b9f456SAndroid Build Coastguard Worker this->clear(); 1747*58b9f456SAndroid Build Coastguard Worker else 1748*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1749*58b9f456SAndroid Build Coastguard Worker} 1750*58b9f456SAndroid Build Coastguard Worker#endif 1751*58b9f456SAndroid Build Coastguard Worker 1752*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 1753*58b9f456SAndroid Build Coastguard Workerinline 1754*58b9f456SAndroid Build Coastguard Workervoid 1755*58b9f456SAndroid Build Coastguard Workerbasic_fstream<_CharT, _Traits>::close() 1756*58b9f456SAndroid Build Coastguard Worker{ 1757*58b9f456SAndroid Build Coastguard Worker if (__sb_.close() == 0) 1758*58b9f456SAndroid Build Coastguard Worker this->setstate(ios_base::failbit); 1759*58b9f456SAndroid Build Coastguard Worker} 1760*58b9f456SAndroid Build Coastguard Worker 1761*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD 1762*58b9f456SAndroid Build Coastguard Worker 1763*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS 1764*58b9f456SAndroid Build Coastguard Worker 1765*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_FSTREAM 1766