Share via


filebuf::open

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

Opens a disk file and attaches it with this filebuf object.

Return Value

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.

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, which is equivalent to the operating system default (filebuf::sh_compat for MS-DOS). The possible values of nProt are:

  • filebuf::sh_compat   Compatibility share mode (MS-DOS only).

  • filebuf::sh_none   Exclusive mode — no sharing.

  • filebuf::sh_read   Read sharing allowed.

  • filebuf::sh_write   Write sharing allowed.

    You can combine the filebuf::sh_read and filebuf::sh_write modes with the logical OR ( || ) operator.

filebuf OverviewStream Buffer Classes

See Also   filebuf::is_open, filebuf::close, filebuf::~filebuf