From 3a425349ec443fcbf144c8f4b0a4e7af6a47547f Mon Sep 17 00:00:00 2001 From: Wayne Warren Date: Sat, 15 Jan 2022 17:58:52 -0700 Subject: [PATCH] RawDevice: introduce system_path() method --- src/raw_stream.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/raw_stream.rs b/src/raw_stream.rs index d6c5a71..3d8f1b0 100644 --- a/src/raw_stream.rs +++ b/src/raw_stream.rs @@ -2,7 +2,7 @@ use std::fs::{File, OpenOptions}; use std::io::Write; use std::mem::MaybeUninit; use std::os::unix::io::{AsRawFd, RawFd}; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::{io, mem}; use crate::constants::*; @@ -68,6 +68,7 @@ pub struct RawDevice { supported_snd: Option>, pub(crate) event_buf: Vec, grabbed: bool, + system_path: PathBuf, } #[derive(Debug, Clone)] @@ -225,6 +226,7 @@ impl RawDevice { auto_repeat, event_buf: Vec::new(), grabbed: false, + system_path: path.to_path_buf(), }) } @@ -383,6 +385,11 @@ impl RawDevice { self.supported_snd.as_deref() } + /// Returns the system path used to open the device. + pub fn system_path(&self) -> &Path { + self.system_path.as_ref() + } + /// Read a maximum of `num` events into the internal buffer. If the underlying fd is not /// O_NONBLOCK, this will block. ///