Boost C++ Libraries

PrevUpHomeNext

Function fopen

boost::filesystem::fopen — Opens a file using C standard library file descriptor.

Synopsis

// In header: <boost/filesystem/cstdio.hpp>


std::FILE * fopen(filesystem::path const & p, const char * mode);

Description

This function is equivalent to std::fopen from <cstdio> with the only difference being that the path argument is expressed as const path&. The function attempts to open the file without path character encoding conversion, permitting non-ASCII characters in filesystem paths. If the function does perform character code conversion, it does so by calling path methods, using the locale facet returned by path::codecvt.

Error Reporting: 

C standard library and system errors are reported using the return value of a null pointer and errno mechanism. An exception may be thrown by one of the path methods, if called by the implementation.

[Note] Note

In particular, path::string may be called on a platform that uses wchar_t as the native path character type but does not provide a low level API to open a file using a wide character path. This is the case on the legacy MinGW32 in strict mode, for instance.

Parameters:

p

Path to the file.

mode

File opening mode. Refer to std::fopen documentation for the supported modes.

Returns:

If the file has been opened successfully, a pointer to the file descriptor, to be closed with std::fclose. Otherwise, a null pointer and errno is set to the error code. Refer to std::fopen documentation for the list of error codes.


PrevUpHomeNext