Determines whether a link resolves to an actual object
H5O_EXISTS_BY_NAME(loc_id, name, lapl_id)
htri_t H5Oexists_by_name( hid_t loc_id, const char * name, hid_t lapl_id )
SUBROUTINE h5oexists_by_name_f(loc_id, name, link_exists, & hdferr, lapl_id) IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: loc_id CHARACTER(LEN=*), INTENT(IN) :: name LOGICAL , INTENT(OUT) :: link_exists INTEGER , INTENT(OUT) :: hdferr INTEGER(HID_T) , INTENT(IN), OPTIONAL :: lapl_id
|hid_t ||IN: Location Identifier to query; may be a file, group, dataset, named datatype or attribute identifier|
|const char *||IN: The name of the link to check|
|hid_t ||IN: Link access property list identifier|
H5O_EXISTS_BY_NAME allows an application to determine whether the link
name in the group or file specified with
loc_id resolves to an HDF5 object to open or if the link dangles. The link may be of any type, but hard links will always resolve to objects and do not need to be verified.
Note that H5O_EXISTS_BY_NAME verifies only that the target object exists. If
name includes either a relative path or an absolute path to the target link, intermediate steps along the path must be verified before the existence of the target link can be safely checked. If the path is not verified and an intermediate element of the path does not exist, H5O_EXISTS_BY_NAME will fail. The example in the next paragraph illustrates one step-by-step method for verifying the existence of a link with a relative or absolute path.
Example: Use the following steps to verify the existence of the link
datasetD in the group
group1 is a member of the group specified by
- First use H5L_EXISTS to verify that a link named
group1exists, use H5O_EXISTS_BY_NAME to verify that the link
group1resolves to an object.
group1exists, use H5L_EXISTS again, this time with
group1/group2, to verify that the link
- If the
group2link exists, use H5O_EXISTS_BY_NAME to verify that
group1/group2resolves to an object.
group2exists, use H5L_EXISTS again, this time with
group1/group2/softlink_to_group3, to verify that the link
- If the
softlink_to_group3link exists, use H5O_EXISTS_BY_NAME to verify that
group1/group2/softlink_to_group3resolves to an object.
softlink_to_group3exists, you can now safely use H5L_EXISTS with
group1/group2/softlink_to_group3/datasetDto verify that the target link,
- And finally, if the link
datasetDexists, use H5O_EXISTS_BY_NAME to verify that
group1/group2/softlink_to_group3/datasetDresolves to an object.
If the link to be verified is specified with an absolute path, the same approach should be used, but starting with the first link in the file’s root group. For instance, if
datasetD were in
/group1/group2/softlink_to_group3, the first call to H5L_EXISTS would have
name set to
Note that this is an outline and does not include all necessary details. Depending on circumstances, for example, an application may need to verify the type of an object also.
Returns a positive value if the object pointed to by the
name combination exists.
Returns 0 if the object pointed to by the
name combination does not exist.
Returns a negative value when the function fails.
name both exist but the combination does not resolve to an object, the function will return 0 (zero); the function does not fail in this case.
If either the location or the link specified by the
name combination does not exist, the function will fail, returning a negative value.
Note that verifying the existence of an object within an HDF5 file is a multistep process. An application can be certain the object does not exist only if H5L_EXISTS and H5O_EXISTS_BY_NAME have been used to verify the existence of the links and groups in the hierarchy above that object. The example above, in the function description, provides a step-by-step description of that verification process.
|1.8.11||Fortran subroutine introduced in this release.|
|1.8.5||C function introduced in this release.|