Struct bitflags::__core::fs::OpenOptions
[−]
[src]
pub struct OpenOptions(_);1.0.0
Options and flags which can be used to configure how a file is opened.
This builder exposes the ability to configure how a File
is opened and
what operations are permitted on the open file. The File::open
and
File::create
methods are aliases for commonly used options using this
builder.
Generally speaking, when using OpenOptions
, you'll first call new()
,
then chain calls to methods to set each option, then call open()
, passing
the path of the file you're trying to open. This will give you a
io::Result
with a File
inside that you can further
operate on.
Examples
Opening a file to read:
use std::fs::OpenOptions; let file = OpenOptions::new().read(true).open("foo.txt");
Opening a file for both reading and writing, as well as creating it if it doesn't exist:
use std::fs::OpenOptions; let file = OpenOptions::new() .read(true) .write(true) .create(true) .open("foo.txt");