feat: nix_store::store add real_path function

(cherry picked from commit 3e421e39a6adf9eca412368a92c0e459e9b9f628)
This commit is contained in:
Tristan Ross 2025-09-22 12:25:23 -07:00 committed by Robert Hensing
parent 41c99e02cf
commit e68ec02d05

View file

@ -217,6 +217,21 @@ impl Store {
}
}
#[doc(alias = "nix_store_real_path")]
pub fn real_path(&mut self, path: &StorePath) -> Result<String> {
let mut r = result_string_init!();
unsafe {
check_call!(raw::store_real_path(
&mut self.context,
self.inner.ptr(),
path.as_ptr(),
Some(callback_get_result_string),
callback_get_result_string_data(&mut r)
))
}?;
r
}
pub fn weak_ref(&self) -> StoreWeak {
StoreWeak {
inner: Arc::downgrade(&self.inner),
@ -286,7 +301,9 @@ mod tests {
let store_path_string =
format!("{store_dir}/rdd4pnr4x9rqc9wgbibhngv217w2xvxl-bash-interactive-5.2p26");
let store_path = store.parse_store_path(store_path_string.as_str()).unwrap();
let real_store_path = store.real_path(&store_path).unwrap();
assert_eq!(store_path.name().unwrap(), "bash-interactive-5.2p26");
assert_eq!(real_store_path, store_path_string);
}
#[test]