1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 09:31:16 +02:00

libexpr-c: Add nix_store_path_name

This commit is contained in:
Robert Hensing 2024-04-08 13:14:03 +02:00
parent a512f4eebc
commit f2522d4ecd
3 changed files with 22 additions and 2 deletions

View file

@ -128,6 +128,13 @@ nix_err nix_store_realise(
NIXC_CATCH_ERRS
}
void nix_store_path_name(const StorePath *store_path, void * callback, void * user_data)
{
std::string_view name = store_path->path.name();
((nix_get_string_callback) callback)(name.data(), name.size(), user_data);
}
void nix_store_path_free(StorePath * sp)
{
delete sp;

View file

@ -90,6 +90,15 @@ nix_err nix_store_get_uri(nix_c_context * context, Store * store, void * callbac
*/
StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const char * path);
/**
* @brief Get the path name (e.g. "name" in /nix/store/...-name)
*
* @param[in] store_path the path to get the name from
* @param[in] callback called with the name
* @param[in] user_data arbitrary data, passed to the callback when it's called.
*/
void nix_store_path_name(const StorePath *store_path, void * callback, void * user_data);
/**
* @brief Copy a StorePath
*