filebuf* open( const char* szName, int nMode, int nProt = filebuf::openprot );
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.
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.