Boost C++ 库

...世界上最受推崇和专业设计的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu,《C++ 编码标准

PrevUpHomeNext
basic_file::open (4 个重载中的第 4 个)

使用指定的路径打开文件。

void open(
    const std::string & path,
    file_base::flags open_flags,
    boost::system::error_code & ec);

此函数打开文件,以便它将使用指定的路径。

参数

path

标识要打开文件的路径名。

open_flags

一组标志,用于确定文件应如何打开。

ec

设置为指示发生了什么错误(如果有)。

必须指定以下 file_base::flags 值之一

以下标志可以按位或运算进行添加

示例
boost::asio::stream_file file(my_context);
boost::system::error_code ec;
file.open("/path/to/my/file", boost::asio::stream_file::read_only, ec);
if (ec)
{
  // An error occurred.
}

PrevUpHomeNext