Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
basic_filebuf::open
basic_filebuf *open(const char *s, ios_base::openmode mode);
The member function endeavors to open the file with file name s, by calling fopen``(s, strmode). Here strmode is determined from mode & ~(ate& |binary):
ios_base::inbecomes"r"(open existing file for reading).ios_base::outorios_base::``out`` | ios_base::truncbecomes"w"(truncate existing file or create for writing).ios_base::``out`` |appbecomes"a"(open existing file for appending all writes).ios_base::``in`` | ios_base::``outbecomes"r+"(open existing file for reading and writing).ios_base::``in`` | ios_base::``out`` | ios_base::``truncbecomes"w+"(truncate existing file or create for reading and writing).ios_base::``in`` | ios_base::``out`` | ios_base::``appbecomes"a+"(open existing file for reading and for appending all writes).
If mode & ios_base::``binary is nonzero, the function appends b to strmode to open a binary stream instead of a text stream. It then stores the value returned by fopen in the file pointerfp. If mode & ios_base::``ate is nonzero and the file pointer is not a null pointer, the function calls fseek``(fp, 0, ``SEEK_END``) to position the stream at end-of-file. If that positioning operation fails, the function calls close(fp) and stores a null pointer in the file pointer.
If the file pointer is not a null pointer, the function determines the file conversion facetuse_facet< codecvt<E, char, T::state_type> >(getloc()), for use by underflow and overflow.
If the file pointer is a null pointer, the function returns a null pointer. Otherwise, it returns this.