Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/libstore-c/nix_api_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,34 @@ StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const c
NIXC_CATCH_ERRS_NULL
}

nix_err nix_store_get_fs_closure(
nix_c_context * context,
Store * store,
const StorePath * store_path,
bool flip_direction,
bool include_outputs,
bool include_derivers,
void * userdata,
void (*callback)(void * userdata, const StorePath * store_path))
{
if (context)
context->last_err_code = NIX_OK;
try {
const auto nixStore = store->ptr;

nix::StorePathSet set;
nixStore->computeFSClosure(store_path->path, set, flip_direction, include_outputs, include_derivers);

if (callback) {
for (const auto & path : set) {
const StorePath tmp{path};
callback(userdata, &tmp);
}
}
}
NIXC_CATCH_ERRS
}

nix_err nix_store_realise(
nix_c_context * context,
Store * store,
Expand Down
24 changes: 24 additions & 0 deletions src/libstore-c/nix_api_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,30 @@ void nix_derivation_free(nix_derivation * drv);
*/
nix_err nix_store_copy_closure(nix_c_context * context, Store * srcStore, Store * dstStore, StorePath * path);

/**
* @brief Gets the closure of a specific store path
*
* @note The callback borrows each StorePath only for the duration of the call.
*
* @param[out] context Optional, stores error information
* @param[in] store nix store reference
* @param[in] store_path The path to compute from
* @param[in] flip_direction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roberth is the right thing to just copy the doc from the C++ function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the docs are good, then that's fine

* @param[in] include_outputs
* @param[in] include_derivers
* @param[in] callback The function to call for every store path, in no particular order
* @param[in] userdata The userdata to pass to the callback
*/
nix_err nix_store_get_fs_closure(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to put this above nix_store_realise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

nix_c_context * context,
Store * store,
const StorePath * store_path,
bool flip_direction,
bool include_outputs,
bool include_derivers,
void * userdata,
void (*callback)(void * userdata, const StorePath * store_path));

// cffi end
#ifdef __cplusplus
}
Expand Down
Loading