Skip to content

Commit 2577b8d

Browse files
committed
Add get_keys method to SCDynamicStore
1 parent ca23c24 commit 2577b8d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

system-configuration/src/dynamic_store.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,25 @@ impl SCDynamicStore {
168168
}
169169
}
170170

171+
/// Returns the keys that represent the current dynamic store entries that match the specified
172+
/// pattern. Or `None` if an error occured.
173+
///
174+
/// `pattern` - A regular expression pattern used to match the dynamic store keys.
175+
pub fn get_keys<S: Into<CFString>>(&self, pattern: S) -> Option<CFArray<CFString>> {
176+
let cf_pattern = pattern.into();
177+
unsafe {
178+
let array_ref = SCDynamicStoreCopyKeyList(
179+
self.as_concrete_TypeRef(),
180+
cf_pattern.as_concrete_TypeRef(),
181+
);
182+
if array_ref != ptr::null() {
183+
Some(CFArray::wrap_under_create_rule(array_ref))
184+
} else {
185+
None
186+
}
187+
}
188+
}
189+
171190
/// If the given key exists in the store, the associated value is returned.
172191
///
173192
/// Use `CFPropertyList::downcast` to cast the result into the correct type.

0 commit comments

Comments
 (0)