summaryrefslogtreecommitdiffstats
path: root/src/H5Gloc.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-25 04:10:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-25 04:10:32 (GMT)
commit5c1fedcb9003ab614db83a15723bb0fc0389e3c7 (patch)
treeec8d663d5767b75a432d3d91c5cbb0a84db55530 /src/H5Gloc.c
parent2f694358c4c7ae4fa79057ae7d87f95859fbea73 (diff)
downloadhdf5-5c1fedcb9003ab614db83a15723bb0fc0389e3c7.zip
hdf5-5c1fedcb9003ab614db83a15723bb0fc0389e3c7.tar.gz
hdf5-5c1fedcb9003ab614db83a15723bb0fc0389e3c7.tar.bz2
[svn-r12973] Description:
Finish removing library's internal code that uses H5G_get_objinfo() and retarget it at either getting the link information or the object information, as appropriate. (Still need to add user-level tests for H5Oget_info(), but since several internal components of the library depend on the internal version, it appears to be working correctly). Tested on: FreeBSD/32 4.11 (sleipnir) Linux/322.4 (heping) Linux/64 2.4 (mir) AIX/32 5.? (copper) Mac OS X/32 10.4.8 (amazon)
Diffstat (limited to 'src/H5Gloc.c')
-rw-r--r--src/H5Gloc.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/H5Gloc.c b/src/H5Gloc.c
index 89f2861..bdd41a5 100644
--- a/src/H5Gloc.c
+++ b/src/H5Gloc.c
@@ -68,6 +68,15 @@ typedef struct {
H5G_loc_t *loc; /* Group location to set */
} H5G_loc_fbi_t;
+/* User data for getting an object's info in a group */
+typedef struct {
+ /* downward */
+ hid_t dxpl_id; /* DXPL to use for operation */
+
+ /* upward */
+ H5O_info_t *oinfo; /* Object information to retrieve */
+} H5G_loc_info_t;
+
/********************/
/* Local Prototypes */
@@ -551,3 +560,81 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_loc_insert() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_loc_info_cb
+ *
+ * Purpose: Callback for retrieving object info for an object in a group
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 23, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5G_loc_info_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, const H5O_link_t UNUSED *lnk,
+ H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/)
+{
+ H5G_loc_info_t *udata = (H5G_loc_info_t *)_udata; /* User data passed in */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5G_loc_info_cb)
+
+ /* Check if the name in this group resolved to a valid link */
+ if(obj_loc == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist")
+
+ /* Query object information */
+ if(H5O_get_info(obj_loc->oloc, udata->oinfo, udata->dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object info")
+
+done:
+ /* Indicate that this callback didn't take ownership of the group *
+ * location for the object */
+ *own_loc = H5G_OWN_NONE;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_loc_info_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_loc_info
+ *
+ * Purpose: Retrieve the information for an object from a group location
+ * and path to that object
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 23, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_loc_info(H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/,
+ hid_t lapl_id, hid_t dxpl_id)
+{
+ H5G_loc_info_t udata; /* User data for traversal callback */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_loc_info, FAIL)
+
+ /* Check args. */
+ HDassert(loc);
+ HDassert(name && *name);
+ HDassert(oinfo);
+
+ /* Set up user data for locating object */
+ udata.dxpl_id = dxpl_id;
+ udata.oinfo = oinfo;
+
+ /* Traverse group hierarchy to locate object */
+ if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G_loc_info_cb, &udata, lapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_loc_info() */
+