filebuf::open

Syntax

filebuf* open( const char* szName, int nMode, int nProt = filebuf::openprot );

Parameters

szName

The name of the file to be opened during construction.

nMode

An integer containing mode bits defined as ios enumerators that can be combined with the OR (|) operator. See the ofstream constructor for a list of the enumerators.

nProt

The file protection specification; defaults to the static integer filebuf::openprot that is equivalent to filebuf::sh_compat. The possible nProt values are as follows:

Value Meaning

filebuf::sh_compat Compatibility share mode.
filebuf::sh_none Exclusive mode—no sharing.
,  
filebuf::sh_read Read sharing allowed.
filebuf::sh_write Write sharing allowed.

The filebuf::sh_read and filebuf::sh_write modes can be combined with the logical OR (|) operator.

Remarks

Opens a disk file and attaches it with this filebuf object. If the file is already open, or if there is an error while opening the file, the function returns NULL; otherwise it returns the filebuf address.

See Also

filebuf::is_open, filebuf::close, filebuf::filebuf