Trait rsfs::unix_ext::OpenOptionsExt
[−]
[src]
pub trait OpenOptionsExt { fn mode(&mut self, mode: u32) -> &mut Self; fn custom_flags(&mut self, flags: i32) -> &mut Self; }
Unix specific rsfs::OpenOptions
extensions.
Required Methods
fn mode(&mut self, mode: u32) -> &mut Self
Sets the mode bits that a new file will be opened with.
The default mode for new files is 0o666.
Examples
use rsfs::*; use rsfs::unix_ext::*; use rsfs::mem::FS; let fs = FS::new(); let mut options = fs.new_openopts(); options.mode(0o600); // only owner can read/write let file = options.open("foo.txt")?;
fn custom_flags(&mut self, flags: i32) -> &mut Self
Pass custom flags to the flags
argument of open
.
The bits that define the access mode are masked out with O_ACCMODE
to ensure they do not
interfere with the access mode set by Rust options.
custom_flags
can only set flags, not remove flags set by Rust options. This option
overwrites any previously set custom flags.
Examples
use rsfs::*; use rsfs::unix_ext::*; use rsfs::mem::FS; let fs = FS::new(); let mut options = fs.new_openopts(); options.write(true); if cfg!(unix) { options.custom_flags(0x8000); // O_NOFOLLOW (use libc in real code) } let file = options.open("foo.txt")?;
Implementors
impl OpenOptionsExt for rsfs::disk::OpenOptions
impl OpenOptionsExt for rsfs::mem::OpenOptions
impl OpenOptionsExt for rsfs::mem::unix::OpenOptions