Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2021-02-03 10:07:34 +0300
committerGabriel Schulhof <gabriel.schulhof@intel.com>2021-02-10 10:34:30 +0300
commitad3ebed046ef457530b046f2a62313a7e16b7e29 (patch)
tree26a3e1308a5989eeb4c64dba0ffc99ece41ea784 /src/node_api.h
parent79d44baae28d64e0a0ee1765df3eb637e429e7a6 (diff)
node-api: allow retrieval of add-on file name
Unlike JS-only modules, native add-ons are always associated with a dynamic shared object from which they are loaded. Being able to retrieve its absolute path is important to native-only add-ons, i.e. add-ons that are not themselves being loaded from a JS-only module located in the same package as the native add-on itself. Currently, the file name is obtained at environment construction time from the JS `module.filename`. Nevertheless, the presence of `module` is not required, because the file name could also be passed in via a private property added onto `exports` from the `process.dlopen` binding. As an attempt at future-proofing, the file name is provided as a URL, i.e. prefixed with the `file://` protocol. Fixes: https://github.com/nodejs/node-addon-api/issues/449 PR-URL: https://github.com/nodejs/node/pull/37195 Co-authored-by: Michael Dawson <mdawson@devrus.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'src/node_api.h')
-rw-r--r--src/node_api.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/node_api.h b/src/node_api.h
index 786988e296b..e7be240cdcc 100644
--- a/src/node_api.h
+++ b/src/node_api.h
@@ -261,6 +261,9 @@ NAPI_EXTERN napi_status napi_add_async_cleanup_hook(
NAPI_EXTERN napi_status napi_remove_async_cleanup_hook(
napi_async_cleanup_hook_handle remove_handle);
+NAPI_EXTERN napi_status
+node_api_get_module_file_name(napi_env env, const char** result);
+
#endif // NAPI_EXPERIMENTAL
EXTERN_C_END