File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ Configure and run event loop:
3535
3636``` rust
3737use input :: {Libinput , LibinputInterface };
38- use libc :: {O_RDONLY , O_RDWR , O_WRONLY };
38+ use libc :: {O_ACCMODE , O_RDONLY , O_RDWR , O_WRONLY };
3939use std :: fs :: {File , OpenOptions };
4040use std :: os :: unix :: {fs :: OpenOptionsExt , io :: OwnedFd };
4141use std :: path :: Path ;
@@ -46,8 +46,8 @@ impl LibinputInterface for Interface {
4646 fn open_restricted (& mut self , path : & Path , flags : i32 ) -> Result <OwnedFd , i32 > {
4747 OpenOptions :: new ()
4848 . custom_flags (flags )
49- . read ((flags & O_RDONLY != 0 ) | (flags & O_RDWR != 0 ))
50- . write ((flags & O_WRONLY != 0 ) | (flags & O_RDWR != 0 ))
49+ . read ((flags & O_ACCMODE == O_RDONLY ) | (flags & O_ACCMODE == O_RDWR ))
50+ . write ((flags & O_ACCMODE == O_WRONLY ) | (flags & O_ACCMODE == O_RDWR ))
5151 . open (path )
5252 . map (| file | file . into ())
5353 . map_err (| err | err . raw_os_error (). unwrap ())
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ impl Libinput {
351351 /// # use std::fs::{File, OpenOptions};
352352 /// # use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd};
353353 /// # use std::path::Path;
354- /// # use libc::{O_RDONLY, O_RDWR, O_WRONLY};
354+ /// # use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
355355 /// #
356356 /// use input::{Libinput, LibinputInterface};
357357 /// use rustix::event::{poll, PollFlags, PollFd};
@@ -362,8 +362,8 @@ impl Libinput {
362362 /// # fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
363363 /// # OpenOptions::new()
364364 /// # .custom_flags(flags)
365- /// # .read((flags & O_RDONLY != 0 ) | (flags & O_RDWR != 0 ))
366- /// # .write((flags & O_WRONLY != 0 ) | (flags & O_RDWR != 0 ))
365+ /// # .read((flags & O_ACCMODE == O_RDONLY ) | (flags & O_ACCMODE == O_RDWR ))
366+ /// # .write((flags & O_ACCMODE == O_WRONLY ) | (flags & O_ACCMODE == O_RDWR ))
367367 /// # .open(path)
368368 /// # .map(|file| file.into())
369369 /// # .map_err(|err| err.raw_os_error().unwrap())
Original file line number Diff line number Diff line change 3939//! use std::path::Path;
4040//!
4141//! extern crate libc;
42- //! use libc::{O_RDONLY, O_RDWR, O_WRONLY};
42+ //! use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
4343//!
4444//! struct Interface;
4545//!
4646//! impl LibinputInterface for Interface {
4747//! fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
4848//! OpenOptions::new()
4949//! .custom_flags(flags)
50- //! .read((flags & O_RDONLY != 0 ) | (flags & O_RDWR != 0 ))
51- //! .write((flags & O_WRONLY != 0 ) | (flags & O_RDWR != 0 ))
50+ //! .read((flags & O_ACCMODE == O_RDONLY ) | (flags & O_ACCMODE == O_RDWR ))
51+ //! .write((flags & O_ACCMODE == O_WRONLY ) | (flags & O_ACCMODE == O_RDWR ))
5252//! .open(path)
5353//! .map(|file| file.into())
5454//! .map_err(|err| err.raw_os_error().unwrap())
You can’t perform that action at this time.
0 commit comments