feat: nix_store::store add real_path function
(cherry picked from commit 3e421e39a6adf9eca412368a92c0e459e9b9f628)
This commit is contained in:
parent
41c99e02cf
commit
e68ec02d05
1 changed files with 17 additions and 0 deletions
|
|
@ -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 {
|
pub fn weak_ref(&self) -> StoreWeak {
|
||||||
StoreWeak {
|
StoreWeak {
|
||||||
inner: Arc::downgrade(&self.inner),
|
inner: Arc::downgrade(&self.inner),
|
||||||
|
|
@ -286,7 +301,9 @@ mod tests {
|
||||||
let store_path_string =
|
let store_path_string =
|
||||||
format!("{store_dir}/rdd4pnr4x9rqc9wgbibhngv217w2xvxl-bash-interactive-5.2p26");
|
format!("{store_dir}/rdd4pnr4x9rqc9wgbibhngv217w2xvxl-bash-interactive-5.2p26");
|
||||||
let store_path = store.parse_store_path(store_path_string.as_str()).unwrap();
|
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!(store_path.name().unwrap(), "bash-interactive-5.2p26");
|
||||||
|
assert_eq!(real_store_path, store_path_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue