diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Gdeprec.c | 99 | ||||
-rw-r--r-- | src/H5Gpublic.h | 2 |
2 files changed, 51 insertions, 50 deletions
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 9145b3b..bf90f1e 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -787,6 +787,56 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, done: FUNC_LEAVE_API(ret_value) } /* end H5Giterate() */ + + +/*------------------------------------------------------------------------- + * Function: H5Gget_num_objs + * + * Purpose: Returns the number of objects in the group. It iterates + * all B-tree leaves and sum up total number of group members. + * + * Note: Deprecated in favor of H5Gget_info + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Raymond Lu + * Nov 20, 2002 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) +{ + H5G_loc_t loc; /* Location of object */ + H5G_info_t grp_info; /* Group information */ + H5O_type_t obj_type; /* Type of object at location */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(H5Gget_num_objs, FAIL) + H5TRACE2("e", "i*h", loc_id, num_objs); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if(!num_objs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") + + /* Retrieve information about the group */ + if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine") + + /* Set the number of objects [sic: links] in the group */ + *num_objs = grp_info.nlinks; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_num_objs() */ + #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1022,52 +1072,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_objinfo() */ - -/*------------------------------------------------------------------------- - * Function: H5Gget_num_objs - * - * Purpose: Returns the number of objects in the group. It iterates - * all B-tree leaves and sum up total number of group members. - * - * Note: Deprecated in favor of H5Gget_info - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) -{ - H5G_loc_t loc; /* Location of object */ - H5G_info_t grp_info; /* Group information */ - H5O_type_t obj_type; /* Type of object at location */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(H5Gget_num_objs, FAIL) - H5TRACE2("e", "i*h", loc_id, num_objs); - - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - if(!num_objs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") - - /* Retrieve information about the group */ - if(H5G_obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine") - - /* Set the number of objects [sic: links] in the group */ - *num_objs = grp_info.nlinks; - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Gget_num_objs() */ - diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 6e6560c..6f4bc00 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -133,7 +133,6 @@ H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name, H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); -H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. @@ -175,6 +174,7 @@ H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf); H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5G_iterate_t op, void *op_data); +H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); #endif /* H5_NO_DEPRECATED_SYMBOLS */ |