Skip to content

Commit

Permalink
Add the missing get_string_or_ret macro
Browse files Browse the repository at this point in the history
  • Loading branch information
breard-r committed Dec 6, 2024
1 parent 5ed51f8 commit fd932b0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ macro_rules! get_bytes_or_ret {
}};
}

#[cfg(not(unix))]
macro_rules! get_string_or_ret {
($ret: ident, $entry: ident, $key: expr) => {{
let value = get_attr_or_ret!($ret, $entry, $key);
if let Some(s) = value.as_str() {
std::ffi::OsStr::new(s).to_os_string()
} else {
warn!("unable to get string: {:?}", value);
return $ret;
}
}};
}

#[derive(Clone, Debug, Serialize)]
pub struct EntryTemplate {
#[cfg(unix)]
Expand Down

0 comments on commit fd932b0

Please sign in to comment.