H5L_CREATE_EXTERNAL creates a new external link. An external link is a soft link to an object in a different HDF5 file from the location of the link, i.e., to an external object. target_file_name identifies the target file containing the target object; target_obj_name specifies the path of the target object within that file. target_obj_name must be an absolute pathname in target_file_name , i.e., it must start at the target file’s root group, but it is not interpreted until an application attempts to traverse it.
link_loc_id and link_name specify the location and name, respectively, of the new link. link_name is interpreted relative to link_loc_id
lcpl_id is the link creation property list used in creating the new link.
lapl_id is the link access property list used in traversing the new link. Note that an external file opened by the traversal of an external link is always opened with the weak file close degree property setting, H5F_CLOSE_WEAK (see H5P_SET_FCLOSE_DEGREE); any file close degree property setting in lapl_id is ignored.
An external link behaves similarly to a soft link, and like a soft link in an HDF5 file, it may dangle: the target file and object need not exist at the time that the external link is created. When the external link link_name is accessed, the library will search for the target file target_file_name as described below: - If
target_file_name is a relative pathname, the following steps are performed:- The library will get the prefix(es) set in the environment variable
HDF5_EXT_PREFIX and will try to prepend each prefix to target_file_name to form a new target_file_name . - If the new
target_file_name does not exist or if HDF5_EXT_PREFIX is not set, the library will get the prefix set via H5P_SET_ELINK_PREFIX and prepend it to target_file_name to form a new target_file_name . - If the new
target_file_name does not exist or no prefix is being set by H5P_SET_ELINK_PREFIX, then the path of the file associated with link_loc_id is obtained. This path can be the absolute path or the current working directory plus the relative path of that file when it is created/opened. The library will prepend this path to target_file_name to form a new target_file_name . - If the new
target_file_name does not exist, then the library will look for target_file_name and will return failure/success accordingly.
- If
target_file_name is an absolute pathname, the library will first try to find target_file_name . If target_file_name does not exist, target_file_name is stripped of directory paths to form a new target_file_name . The search for the new target_file_name then follows the same steps as described above for a relative pathname. See examples below illustrating how target_file_name is stripped to form a new target_file_name .
Note that target_file_name is considered to be an absolute pathname when the following condition is true: The library opens target file target_file_name with the file access property list that is set via H5P_SET_ELINK_FAPL when the external link link_name is accessed. If no such property list is set, the library uses the file access property list associated with the file of link_loc_id to open the target file. If an application requires additional control over file access flags or the file access property list, see H5P_SET_ELINK_CB; this function enables the use of an external link callback function as described in H5L_ELINK_TRAVERSE_T. Restriction: A file close degree property setting (H5P_SET_FCLOSE_DEGREE) in the external link file access property list or in the external link callback function will be ignored. A file opened by means of traversing an external link is always opened with the weak file close degree property setting, H5F_CLOSE_WEAK . |