filebuf

#include <fstream.h>

The filebuf class is a derived class of streambuf that is specialized for buffered disk file I/O. The buffering is managed entirely within the Microsoft iostream Class Library. filebuf member functions call the run-time low-level I/O routines (the functions declared in IO.H) such as _sopen, _read, and _write.

The file stream classes, ofstream, ifstream, and fstream, use filebuf member functions to fetch and store characters. Some of these member functions are virtual functions of the streambuf class.

The reserve area, put area, and get area are introduced in the streambuf class description. The put area and the get area are always the same for filebuf objects. Also, the get pointer and put pointers are tied; when one moves, so does the other.

Construction/Destruction — Public Members

filebuf

Constructs a filebuf object.

~filebuf

Destroys a filebuf object.

Operations — Public Members

open

Opens a file and attaches it to the filebuf object.

close

Flushes any waiting output and closes the attached file.

setmode

Sets the file’s mode to binary or text.

attach

Attaches the filebuf object to an open file.

Status/Information — Public Members

fd

Returns the stream’s file descriptor.

is_open

Tests whether the file is open.

Stream Buffer Classes

See Also   ifstream, ofstream, streambuf, strstreambuf, stdiobuf