Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
filebuf
fstream
ifstream
ios
iostream
ios_base
istream
istringstream
ofstream
ostream
ostringstream
streambuf
stringbuf
stringstream
objects:
cerr
cin
clog
cout
types:
fpos
streamoff
streampos
streamsize
filebuf
filebuf::filebuf
filebuf::~filebuf
member functions:
filebuf::close
filebuf::is_open
filebuf::open
virtual members:
filebuf::imbue
filebuf::overflow
filebuf::pbackfail
filebuf::seekoff
filebuf::seekpos
filebuf::setbuf
filebuf::showmanyc
filebuf::sync
filebuf::uflow
filebuf::underflow


filebuf::is_open

public member function
bool is_open ( );

Check if a file is open

The function returns true if a previous call to open succeeded and there have been no calls to the member close since, meaning that the filebuf object is currently associated with a file.

Parameters

none

Return Value

true if a file is open, i.e. associated to this stream buffer object.
false otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// is_open () example
#include <iostream>
#include <fstream>
using namespace std;
int main () {
  ifstream is;
  filebuf * fb;
  fb = is.rdbuf();
  fb->open ("test.txt",ios::in);
  if ( fb->is_open() )
    cout << "file is open.\n";
  else
    cout << "file is not open.\n";
  fb->close();
  return 0;
}


Basic template member declaration

( basic_filebuf<charT,traits> )
 
bool is_open ( );


See also