![]() |
HDF5
1.15.0.4f01fb3
API Reference
|
Function | Purpose |
---|---|
H5Pset_elink_cb/H5Pget_elink_cb | Sets/gets the external link traversal callback function. |
H5Pset_elink_acc_flags/H5Pget_elink_acc_flags | Sets/gets the external link traversal file access flag. |
H5Pset_elink_fapl/H5Pget_elink_fapl | Sets/gets a file access property list for use in accessing a file pointed to by an external link |
H5Pset_elink_prefix/H5Pget_elink_prefix | Sets/gets prefix to be applied to external link paths. |
H5Pset_nlinks/H5Pget_nlinks | Sets/gets maximum number of soft or user-defined link traversals. |
Modules | |
Dataset Access Properties | |
Datatype Access Properties | |
Group Access Properties | |
Functions | |
herr_t | H5Pget_elink_acc_flags (hid_t lapl_id, unsigned *flags) |
Retrieves the external link traversal file access flag from the specified link access property list. More... | |
herr_t | H5Pget_elink_cb (hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data) |
Retrieves the external link traversal callback function from the specified link access property list. More... | |
hid_t | H5Pget_elink_fapl (hid_t lapl_id) |
Retrieves the file access property list identifier associated with the link access property list. More... | |
ssize_t | H5Pget_elink_prefix (hid_t plist_id, char *prefix, size_t size) |
Retrieves prefix applied to external link paths. More... | |
herr_t | H5Pget_nlinks (hid_t plist_id, size_t *nlinks) |
Retrieves the maximum number of link traversals. More... | |
herr_t | H5Pset_elink_acc_flags (hid_t lapl_id, unsigned flags) |
Sets the external link traversal file access flag in a link access property list. More... | |
herr_t | H5Pset_elink_cb (hid_t lapl_id, H5L_elink_traverse_t func, void *op_data) |
Sets the external link traversal callback function in a link access property list. More... | |
herr_t | H5Pset_elink_fapl (hid_t lapl_id, hid_t fapl_id) |
Sets a file access property list for use in accessing a file pointed to by an external link. More... | |
herr_t | H5Pset_elink_prefix (hid_t plist_id, const char *prefix) |
Sets prefix to be applied to external link paths. More... | |
herr_t | H5Pset_nlinks (hid_t plist_id, size_t nlinks) |
Sets maximum number of soft or user-defined link traversals. More... | |
Retrieves the external link traversal file access flag from the specified link access property list.
[in] | lapl_id | Link access property list identifier |
[out] | flags | File access flag for link traversal |
H5Pget_elink_acc_flags() retrieves the file access flag used to open an external link target file from the specified link access property list.
Valid values for flags
include:
The value returned, if it is not H5F_ACC_DEFAULT, will override the default access flag, which is the access flag used to open the parent file.
Example Usage: The following code retrieves the external link access flag settings on the link access property list lapl_id
into a local variable:
unsigned acc_flags; status = H5Pget_elink_acc_flags(lapl_id, &acc_flags);
herr_t H5Pget_elink_cb | ( | hid_t | lapl_id, |
H5L_elink_traverse_t * | func, | ||
void ** | op_data | ||
) |
Retrieves the external link traversal callback function from the specified link access property list.
[in] | lapl_id | Link access property list identifier |
[out] | func | User-defined external link traversal callback function |
[out] | op_data | User-defined input data for the callback function |
H5Pget_elink_cb() retrieves the user-defined external link traversal callback function defined in the specified link access property list.
The callback function may adjust the file access property list and file access flag to use when opening a file through an external link. The callback will be executed by the HDF5 library immediately before opening the target file.
Failure Modes: H5Pget_elink_cb() will fail if the link access property list identifier, lapl_id
, is invalid.
An invalid function pointer or data pointer, func
or op_data
respectively, may cause a segmentation fault or an invalid memory access.
Example Usage: The following code retrieves the external link callback settings on the link access property list lapl_id
into local variables:
H5L_elink_traverse_t elink_callback_func; void *elink_callback_udata; status = H5Pget_elink_cb (lapl_id, &elink_callback_func, &elink_callback_udata);
Retrieves the file access property list identifier associated with the link access property list.
[in] | lapl_id | Link access property list identifier |
H5Pget_elink_fapl() retrieves the file access property list identifier that is set for the link access property list identifier, lapl_id
. The library uses this file access property list identifier to open the target file for the external link access. When no such identifier is set, this routine returns H5P_DEFAULT.
Retrieves prefix applied to external link paths.
[in] | plist_id | Link access property list identifier |
[out] | prefix | Prefix applied to external link paths |
[in] | size | Size of prefix, including null terminator |
H5Pget_elink_prefix() retrieves the prefix applied to the path of any external links traversed.
When an external link is traversed, the prefix is retrieved from the link access property list plist_id
, returned in the user-allocated buffer pointed to by prefix
, and prepended to the filename stored in the external link.
The size in bytes of the prefix, including the NULL terminator, is specified in size
. If size is unknown, a preliminary H5Pget_elink_prefix() call with the pointer prefix
set to NULL will return the size of the prefix without the NULL terminator.
Retrieves the maximum number of link traversals.
[in] | plist_id | Link access property list identifier |
[out] | nlinks | Maximum number of links to traverse |
H5Pget_nlinks() retrieves the maximum number of soft or user-defined link traversals allowed, nlinks
, before the library assumes it has found a cycle and aborts the traversal. This value is retrieved from the link access property list plist_id
.
The limit on the number of soft or user-defined link traversals is designed to terminate link traversal if one or more links form a cycle. User control is provided because some files may have legitimate paths formed of large numbers of soft or user-defined links. This property can be used to allow traversal of as many links as desired.
Sets the external link traversal file access flag in a link access property list.
[in] | lapl_id | Link access property list identifier |
[in] | flags | The access flag for external link traversal |
H5Pset_elink_acc_flags() specifies the file access flag to use to open the target file of an external link. This allows read-only access of files reached through an external link in a file opened with write access, or vice-versa.
Valid values for flags
include:
lapl_id
, causing the file access flag setting to be taken from the parent fileThe library will normally use the file access flag used to open the parent file as the file access flag for the target file. This function provides a way to override that behavior. The external link traversal callback function set by H5Pset_elink_cb() can override the setting from H5Pset_elink_acc_flags().
Motivation: H5Pset_elink_acc_flags() is used to adjust the file access flag used to open files reached through external links. This may be useful to, for example, prevent modifying files accessed through an external link. Otherwise, the target file is opened with whatever flag was used to open the parent.
Example Usage: The following code sets the link access property list lapl_id
to open external link target files with read-only access:
status = H5Pset_elink_acc_flags(lapl_id, H5F_ACC_RDONLY);
herr_t H5Pset_elink_cb | ( | hid_t | lapl_id, |
H5L_elink_traverse_t | func, | ||
void * | op_data | ||
) |
Sets the external link traversal callback function in a link access property list.
[in] | lapl_id | Link access property list identifier |
[in] | func | User-defined external link traversal callback function |
[in] | op_data | User-defined input data for the callback function |
H5Pset_elink_cb() sets a user-defined external link traversal callback function in the link access property list lapl_id
. The callback function func
must conform to the prototype specified in H5L_elink_traverse_t.
The callback function may adjust the file access property list and file access flags to use when opening a file through an external link. The callback will be executed by the HDF5 library immediately before opening the target file.
The callback will be made after the file access property list set by H5Pset_elink_fapl() and the file access flag set by H5Pset_elink_acc_flags() are applied, so changes made by this callback function will take precedence.
Motivation: H5Pset_elink_cb() is used to specify a callback function that is executed by the HDF5 library when traversing an external link. This provides a mechanism to set specific access permissions, modify the file access property list, modify the parent or target file, or take any other user-defined action. This callback function is used in situations where the HDF5 library's default behavior is not suitable.
Failure Modes: H5Pset_elink_cb() will fail if the link access property list identifier, lapl_id
, is invalid or if the function pointer, func
, is NULL.
An invalid function pointer, func
, will cause a segmentation fault or other failure when an attempt is subsequently made to traverse an external link.
Example Usage: This example defines a callback function that prints the name of the target file every time an external link is followed, and sets this callback function on lapl_id
.
herr_t elink_callback(const char *parent_file_name, const char *parent_group_name, const char *child_file_name, const char *child_object_name, unsigned *acc_flags, hid_t fapl_id, void *op_data) { puts(child_file_name); return 0; } int main(void) { hid_t lapl_id = H5Pcreate(H5P_LINK_ACCESS); H5Pset_elink_cb(lapl_id, elink_callback, NULL); ... }
Sets a file access property list for use in accessing a file pointed to by an external link.
[in] | lapl_id | Link access property list identifier |
[in] | fapl_id | File access property list identifier |
H5Pset_elink_fapl() sets the file access property list, fapl_id
, to be used when accessing the target file of an external link associated with lapl_id
.
Sets prefix to be applied to external link paths.
[in] | plist_id | Link access property list identifier |
[in] | prefix | Prefix to be applied to external link paths |
H5Pset_elink_prefix() sets the prefix to be applied to the path of any external links traversed. The prefix is prepended to the filename stored in the external link.
The prefix is specified in the user-allocated buffer prefix
and set in the link access property list plist_id
. The buffer should not be freed until the property list has been closed.
Sets maximum number of soft or user-defined link traversals.
[in] | plist_id | Link access property list identifier |
[in] | nlinks | Maximum number of links to traverse |
H5Pset_nlinks() sets the maximum number of soft or user-defined link traversals allowed, nlinks
, before the library assumes it has found a cycle and aborts the traversal. This value is set in the link access property list plist_id
.
The limit on the number of soft or user-defined link traversals is designed to terminate link traversal if one or more links form a cycle. User control is provided because some files may have legitimate paths formed of large numbers of soft or user-defined links. This property can be used to allow traversal of as many links as desired.