Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Configure and run event loop:

```rust
use input::{Libinput, LibinputInterface};
use libc::{O_RDONLY, O_RDWR, O_WRONLY};
use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
use std::fs::{File, OpenOptions};
use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd};
use std::path::Path;
Expand All @@ -46,8 +46,8 @@ impl LibinputInterface for Interface {
fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
OpenOptions::new()
.custom_flags(flags)
.read((flags & O_RDONLY != 0) | (flags & O_RDWR != 0))
.write((flags & O_WRONLY != 0) | (flags & O_RDWR != 0))
.read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR))
.write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR))
.open(path)
.map(|file| file.into())
.map_err(|err| err.raw_os_error().unwrap())
Expand Down
6 changes: 3 additions & 3 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl Libinput {
/// # use std::fs::{File, OpenOptions};
/// # use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd};
/// # use std::path::Path;
/// # use libc::{O_RDONLY, O_RDWR, O_WRONLY};
/// # use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
/// #
/// use input::{Libinput, LibinputInterface};
/// use rustix::event::{poll, PollFlags, PollFd};
Expand All @@ -362,8 +362,8 @@ impl Libinput {
/// # fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
/// # OpenOptions::new()
/// # .custom_flags(flags)
/// # .read((flags & O_RDONLY != 0) | (flags & O_RDWR != 0))
/// # .write((flags & O_WRONLY != 0) | (flags & O_RDWR != 0))
/// # .read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR))
/// # .write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR))
/// # .open(path)
/// # .map(|file| file.into())
/// # .map_err(|err| err.raw_os_error().unwrap())
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
//! use std::path::Path;
//!
//! extern crate libc;
//! use libc::{O_RDONLY, O_RDWR, O_WRONLY};
//! use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
//!
//! struct Interface;
//!
//! impl LibinputInterface for Interface {
//! fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
//! OpenOptions::new()
//! .custom_flags(flags)
//! .read((flags & O_RDONLY != 0) | (flags & O_RDWR != 0))
//! .write((flags & O_WRONLY != 0) | (flags & O_RDWR != 0))
//! .read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR))
//! .write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR))
//! .open(path)
//! .map(|file| file.into())
//! .map_err(|err| err.raw_os_error().unwrap())
Expand Down