[svn-r14146] Description:

Move H5Gget_objtype_by_idx() to deprecated symbols section, replacing
with H5Oget_info_by_idx()

Tested on:
        FreeBSD/32 6.2 (duty)
        FreeBSD/64 6.2 (liberty)
        Linux/32 2.6 (kagiso)
        Linux/64 2.6 (smirom)
        AIX/32 5.3 (copper)
        Solaris/32 2.10 (linew)
        Mac OS X/32 10.4.10 (amazon)
This commit is contained in:
Quincey Koziol 2007-09-13 13:26:12 -05:00
parent 095762a736
commit 27a1a10fbb
15 changed files with 442 additions and 444 deletions

View File

@ -1057,6 +1057,7 @@ ssize_t CommonFG::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size)
return (name_len);
}
#ifndef H5_NO_DEPRECATED_SYMBOLS
//--------------------------------------------------------------------------
// Function: CommonFG::getObjTypeByIdx
///\brief Returns the type of an object in this group, given the
@ -1104,6 +1105,8 @@ H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const
}
return (obj_type);
}
#endif /* H5_NO_DEPRECATED_SYMBOLS */
//--------------------------------------------------------------------------
// Function: CommonFG default constructor
///\brief Default constructor.

View File

@ -74,12 +74,12 @@ class H5_DLLCPP CommonFG {
ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const;
H5std_string getObjnameByIdx(hsize_t idx) const;
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Returns the type of an object in this group, given the
// object's index.
H5G_obj_t getObjTypeByIdx(hsize_t idx) const;
H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const;
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Returns information about an HDF5 object, given by its name,
// at this location.
void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const;

View File

@ -141,11 +141,11 @@ int_f
nh5gget_obj_info_idx_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *idx,
_fcd obj_name, int_f *obj_namelen, int_f *obj_type)
{
H5O_info_t oinfo;
hid_t c_loc_id = (hid_t)*loc_id;
char *c_name = NULL;
size_t c_obj_namelen;
char *c_obj_name = NULL;
int type;
hsize_t c_idx = *idx;
hid_t gid = (-1); /* Temporary group ID */
int ret_value = -1;
@ -160,10 +160,9 @@ nh5gget_obj_info_idx_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *idx,
* Allocate buffer to hold name of the object
*/
c_obj_namelen = *obj_namelen;
if(c_obj_namelen) {
if(c_obj_namelen)
if(NULL == (c_obj_name = (char *)HDmalloc(c_obj_namelen + 1)))
goto DONE;
} /* end if */
/* Get a temporary group ID for the group to query */
if((gid = H5Gopen2(c_loc_id, c_name, H5P_DEFAULT)) < 0)
@ -172,10 +171,13 @@ nh5gget_obj_info_idx_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *idx,
/* Query the object's information */
if(H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, c_idx, c_obj_name, c_obj_namelen, H5P_DEFAULT) < 0)
goto DONE;
if((type = H5Gget_objtype_by_idx(gid, c_idx)) == H5G_UNKNOWN)
if(H5Oget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, c_idx, &oinfo, H5P_DEFAULT) < 0)
goto DONE;
*obj_type = type;
/* XXX: Switch from using H5Gget_objtype_by_idx() means that this routine won't
* work on non-hard links - QAK
*/
*obj_type = oinfo.type;
/*
* Convert C name to FORTRAN and place it in the given buffer

View File

@ -258,72 +258,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_compact_get_name_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_compact_get_type_by_idx
*
* Purpose: Returns the type of objects in the group by giving index.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Sep 12, 2005
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo,
hsize_t idx)
{
H5G_link_table_t ltable = {0, NULL}; /* Link table */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_compact_get_type_by_idx, H5G_UNKNOWN)
/* Sanity check */
HDassert(oloc);
/* Build table of all link messages */
if(H5G_compact_build_table(oloc, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_INC, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "can't create link message table")
/* Check for going out of bounds */
if(idx >= ltable.nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5G_UNKNOWN, "index out of bound")
/* Determine type of object */
if(ltable.lnks[idx].type == H5L_TYPE_SOFT)
ret_value = H5G_LINK;
else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN)
ret_value = H5G_UDLINK;
else if(ltable.lnks[idx].type == H5L_TYPE_HARD){
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */
/* Build temporary object location */
tmp_oloc.file = oloc->file;
tmp_oloc.addr = ltable.lnks[idx].u.hard.addr;
/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type")
/* Map to group object type */
if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type)))
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type")
} else {
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type")
} /* end else */
done:
/* Release link table */
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_compact_get_type_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_compact_remove_common_cb
@ -645,3 +579,71 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_compact_lookup_by_idx() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5G_compact_get_type_by_idx
*
* Purpose: Returns the type of objects in the group by giving index.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Sep 12, 2005
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo,
hsize_t idx)
{
H5G_link_table_t ltable = {0, NULL}; /* Link table */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_compact_get_type_by_idx, H5G_UNKNOWN)
/* Sanity check */
HDassert(oloc);
/* Build table of all link messages */
if(H5G_compact_build_table(oloc, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_INC, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "can't create link message table")
/* Check for going out of bounds */
if(idx >= ltable.nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5G_UNKNOWN, "index out of bound")
/* Determine type of object */
if(ltable.lnks[idx].type == H5L_TYPE_SOFT)
ret_value = H5G_LINK;
else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN)
ret_value = H5G_UDLINK;
else if(ltable.lnks[idx].type == H5L_TYPE_HARD){
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */
/* Build temporary object location */
tmp_oloc.file = oloc->file;
tmp_oloc.addr = ltable.lnks[idx].u.hard.addr;
/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type")
/* Map to group object type */
if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type)))
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type")
} else {
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type")
} /* end else */
done:
/* Release link table */
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_compact_get_type_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -1252,82 +1252,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_get_name_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_dense_get_type_by_idx
*
* Purpose: Returns the type of objects in the group by giving index.
*
* Note: This routine assumes a lookup on the link name index in
* increasing order and isn't currently set up to be as
* flexible as other routines in this code module, because
* the H5Gget_objtype_by_idx that it's supporting is
* deprecated.
*
* Return: Success: Non-negative, object type
* Failure: Negative
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
* Sep 19 2006
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
hsize_t idx)
{
H5G_link_table_t ltable = {0, NULL}; /* Table of links */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_dense_get_type_by_idx, H5G_UNKNOWN)
/*
* Check arguments.
*/
HDassert(f);
HDassert(linfo);
/* Build the table of links for this group */
if(H5G_dense_build_table(f, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_INC, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "error building table of links")
/* Check for going out of bounds */
if(idx >= ltable.nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "index out of bound")
/* Determine type of object */
if(ltable.lnks[idx].type == H5L_TYPE_SOFT)
ret_value = H5G_LINK;
else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN)
ret_value = H5G_UDLINK;
else if(ltable.lnks[idx].type == H5L_TYPE_HARD) {
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */
/* Build temporary object location */
tmp_oloc.file = f;
tmp_oloc.addr = ltable.lnks[idx].u.hard.addr;
/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type")
/* Map to group object type */
if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type)))
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type")
} else {
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type")
} /* end else */
done:
/* Release link table */
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_get_type_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_dense_remove_fh_cb
@ -1823,3 +1747,81 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_delete() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5G_dense_get_type_by_idx
*
* Purpose: Returns the type of objects in the group by giving index.
*
* Note: This routine assumes a lookup on the link name index in
* increasing order and isn't currently set up to be as
* flexible as other routines in this code module, because
* the H5Gget_objtype_by_idx that it's supporting is
* deprecated.
*
* Return: Success: Non-negative, object type
* Failure: Negative
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
* Sep 19 2006
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
hsize_t idx)
{
H5G_link_table_t ltable = {0, NULL}; /* Table of links */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_dense_get_type_by_idx, H5G_UNKNOWN)
/*
* Check arguments.
*/
HDassert(f);
HDassert(linfo);
/* Build the table of links for this group */
if(H5G_dense_build_table(f, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_INC, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "error building table of links")
/* Check for going out of bounds */
if(idx >= ltable.nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "index out of bound")
/* Determine type of object */
if(ltable.lnks[idx].type == H5L_TYPE_SOFT)
ret_value = H5G_LINK;
else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN)
ret_value = H5G_UDLINK;
else if(ltable.lnks[idx].type == H5L_TYPE_HARD) {
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */
/* Build temporary object location */
tmp_oloc.file = f;
tmp_oloc.addr = ltable.lnks[idx].u.hard.addr;
/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type")
/* Map to group object type */
if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type)))
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type")
} else {
HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type")
} /* end else */
done:
/* Release link table */
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_dense_get_type_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -85,6 +85,8 @@ static herr_t H5G_get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
H5G_own_loc_t *own_loc/*out*/);
static herr_t H5G_get_objinfo(const H5G_loc_t *loc, const char *name,
hbool_t follow_link, H5G_stat_t *statbuf/*out*/, hid_t dxpl_id);
static H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx,
hid_t dxpl_id);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
@ -1030,8 +1032,6 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Gget_objname_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------
* Function: H5Gget_objtype_by_idx
@ -1074,3 +1074,57 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Gget_objtype_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_obj_get_type_by_idx
*
* Purpose: Private function for H5Gget_objtype_by_idx.
* Returns the type of objects in the group by giving index.
*
* Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3)
*
* Failure: Negative
*
* Programmer: Raymond Lu
* Nov 20, 2002
*
*-------------------------------------------------------------------------
*/
static H5G_obj_t
H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
{
H5O_linfo_t linfo; /* Link info message */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_obj_get_type_by_idx, H5G_UNKNOWN)
/* Sanity check */
HDassert(oloc);
/* Attempt to get the link info for this group */
if(H5G_obj_get_linfo(oloc, &linfo, dxpl_id)) {
if(H5F_addr_defined(linfo.fheap_addr)) {
/* Get the object's name from the dense link storage */
if((ret_value = H5G_dense_get_type_by_idx(oloc->file, dxpl_id, &linfo, idx)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
} /* end if */
else {
/* Get the object's type from the link messages */
if((ret_value = H5G_compact_get_type_by_idx(oloc, dxpl_id, &linfo, idx)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
} /* end else */
} /* end if */
else {
/* Clear error stack from not finding the link info message */
H5E_clear_stack(NULL);
/* Get the object's type from the symbol table */
if((ret_value = H5G_stab_get_type_by_idx(oloc, idx, dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_obj_get_type_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -705,7 +705,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5G_link_obj_type
* Function: H5G_link_name_replace
*
* Purpose: Determine the type of object referred to (for hard links) or
* the link type (for soft links and user-defined links).

View File

@ -827,59 +827,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_obj_get_name_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_obj_get_type_by_idx
*
* Purpose: Private function for H5Gget_objtype_by_idx.
* Returns the type of objects in the group by giving index.
*
* Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3)
*
* Failure: Negative
*
* Programmer: Raymond Lu
* Nov 20, 2002
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
{
H5O_linfo_t linfo; /* Link info message */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_obj_get_type_by_idx, H5G_UNKNOWN)
/* Sanity check */
HDassert(oloc);
/* Attempt to get the link info for this group */
if(H5G_obj_get_linfo(oloc, &linfo, dxpl_id)) {
if(H5F_addr_defined(linfo.fheap_addr)) {
/* Get the object's name from the dense link storage */
if((ret_value = H5G_dense_get_type_by_idx(oloc->file, dxpl_id, &linfo, idx)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
} /* end if */
else {
/* Get the object's type from the link messages */
if((ret_value = H5G_compact_get_type_by_idx(oloc, dxpl_id, &linfo, idx)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
} /* end else */
} /* end if */
else {
/* Clear error stack from not finding the link info message */
H5E_clear_stack(NULL);
/* Get the object's type from the symbol table */
if((ret_value = H5G_stab_get_type_by_idx(oloc, idx, dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_obj_get_type_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_obj_remove_update_linfo

View File

@ -382,8 +382,6 @@ H5_DLL herr_t H5G_stab_bh_size(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab,
H5_ih_info_t *bh_info);
H5_DLL ssize_t H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order,
hsize_t n, char* name, size_t size, hid_t dxpl_id);
H5_DLL H5G_obj_t H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx,
hid_t dxpl_id);
H5_DLL herr_t H5G_stab_remove(H5O_loc_t *oloc, hid_t dxpl_id,
H5RS_str_t *grp_full_path_r, const char *name);
H5_DLL herr_t H5G_stab_remove_by_idx(H5O_loc_t *oloc, hid_t dxpl_id,
@ -392,6 +390,10 @@ H5_DLL herr_t H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name,
H5O_link_t *lnk, hid_t dxpl_id);
H5_DLL herr_t H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order,
hsize_t n, H5O_link_t *lnk, hid_t dxpl_id);
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5_DLL H5G_obj_t H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx,
hid_t dxpl_id);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*
@ -455,8 +457,6 @@ H5_DLL herr_t H5G_compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk,
H5_DLL ssize_t H5G_compact_get_name_by_idx(H5O_loc_t *oloc, hid_t dxpl_id,
const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order,
hsize_t idx, char *name, size_t size);
H5_DLL H5G_obj_t H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id,
const H5O_linfo_t *linfo, hsize_t idx);
H5_DLL herr_t H5G_compact_remove(const H5O_loc_t *oloc, hid_t dxpl_id,
H5RS_str_t *grp_full_path_r, const char *name);
H5_DLL herr_t H5G_compact_remove_by_idx(const H5O_loc_t *oloc, hid_t dxpl_id,
@ -470,6 +470,10 @@ H5_DLL herr_t H5G_compact_lookup(H5O_loc_t *grp_oloc, const char *name,
H5_DLL herr_t H5G_compact_lookup_by_idx(H5O_loc_t *oloc, hid_t dxpl_id,
const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order,
hsize_t n, H5O_link_t *lnk);
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5_DLL H5G_obj_t H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id,
const H5O_linfo_t *linfo, hsize_t idx);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/* Functions that understand "dense" link storage */
H5_DLL herr_t H5G_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
@ -488,8 +492,6 @@ H5_DLL herr_t H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linf
H5_DLL ssize_t H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id,
H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
char *name, size_t size);
H5_DLL H5G_obj_t H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id,
H5O_linfo_t *linfo, hsize_t idx);
H5_DLL herr_t H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
H5RS_str_t *grp_full_path_r, const char *name);
H5_DLL herr_t H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id,
@ -497,6 +499,10 @@ H5_DLL herr_t H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id,
H5_iter_order_t order, hsize_t n);
H5_DLL herr_t H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
hbool_t adj_link);
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5_DLL H5G_obj_t H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id,
H5O_linfo_t *linfo, hsize_t idx);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/* Functions that understand group objects */
H5_DLL herr_t H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo,
@ -511,8 +517,6 @@ H5_DLL herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name,
H5_DLL herr_t H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id);
H5_DLL ssize_t H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id);
H5_DLL H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx,
hid_t dxpl_id);
H5_DLL herr_t H5G_obj_remove(H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r,
const char *name, hid_t dxpl_id);
H5_DLL herr_t H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r,

View File

@ -107,7 +107,6 @@ typedef enum H5G_obj_t {
H5G_RESERVED_7 /* Reserved for future use */
} H5G_obj_t;
H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx);
/* Symbols defined for compatibility with previous versions of the HDF5 API.
*
* Use of these symbols is deprecated.
@ -171,6 +170,7 @@ H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name,
hbool_t follow_link, H5G_stat_t *statbuf/*out*/);
H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name,
size_t size);
H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx);
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -768,116 +768,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_get_name_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_stab_get_type_by_idx_cb
*
* Purpose: Callback for B-tree iteration 'by index' info query to
* retrieve the type of an object
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Nov 7, 2006
*
*-------------------------------------------------------------------------
*/
static herr_t
H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata)
{
H5G_bt_it_gtbi_t *udata = (H5G_bt_it_gtbi_t *)_udata;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_stab_get_type_by_idx_cb)
/* Sanity check */
HDassert(ent);
HDassert(udata);
/* Check for a soft link */
switch(ent->type) {
case H5G_CACHED_SLINK:
udata->type = H5G_LINK;
break;
default:
{
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */
/* Build temporary object location */
tmp_oloc.file = udata->common.f;
HDassert(H5F_addr_defined(ent->header));
tmp_oloc.addr = ent->header;
/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type, udata->dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
udata->type = H5G_map_obj_type(obj_type);
}
break;
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_get_type_by_idx_cb */
/*-------------------------------------------------------------------------
* Function: H5G_get_objtype_by_idx
*
* Purpose: Private function for H5Gget_objtype_by_idx.
* Returns the type of objects in the group by giving index.
*
* Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3)
*
* Failure: UNKNOWN
*
* Programmer: Raymond Lu
* Nov 20, 2002
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
{
H5O_stab_t stab; /* Info about local heap & B-tree */
H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_get_type_by_idx, H5G_UNKNOWN)
/* Sanity check */
HDassert(oloc);
/* Get the B-tree & local heap info */
if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab, dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "unable to determine local heap address")
/* Set iteration information */
udata.common.f = oloc->file;
udata.common.idx = idx;
udata.common.num_objs = 0;
udata.common.op = H5G_stab_get_type_by_idx_cb;
udata.dxpl_id = dxpl_id;
udata.type = H5G_UNKNOWN;
/* Iterate over the group members */
if(H5B_iterate(oloc->file, dxpl_id, H5B_SNODE, H5G_node_by_idx, stab.btree_addr, &udata) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "iteration operator failed")
/* If we don't know the type now, we almost certainly went out of bounds */
if(udata.type == H5G_UNKNOWN)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "index out of bound")
/* Set the return value */
ret_value = udata.type;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_get_type_by_idx() */
/*-------------------------------------------------------------------------
* Function: H5G_stab_lookup_cb
@ -1089,3 +979,115 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_lookup_by_idx() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5G_stab_get_type_by_idx_cb
*
* Purpose: Callback for B-tree iteration 'by index' info query to
* retrieve the type of an object
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Nov 7, 2006
*
*-------------------------------------------------------------------------
*/
static herr_t
H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata)
{
H5G_bt_it_gtbi_t *udata = (H5G_bt_it_gtbi_t *)_udata;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_stab_get_type_by_idx_cb)
/* Sanity check */
HDassert(ent);
HDassert(udata);
/* Check for a soft link */
switch(ent->type) {
case H5G_CACHED_SLINK:
udata->type = H5G_LINK;
break;
default:
{
H5O_loc_t tmp_oloc; /* Temporary object location */
H5O_type_t obj_type; /* Type of object at location */
/* Build temporary object location */
tmp_oloc.file = udata->common.f;
HDassert(H5F_addr_defined(ent->header));
tmp_oloc.addr = ent->header;
/* Get the type of the object */
if(H5O_obj_type(&tmp_oloc, &obj_type, udata->dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
udata->type = H5G_map_obj_type(obj_type);
}
break;
} /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_get_type_by_idx_cb */
/*-------------------------------------------------------------------------
* Function: H5G_get_objtype_by_idx
*
* Purpose: Private function for H5Gget_objtype_by_idx.
* Returns the type of objects in the group by giving index.
*
* Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3)
*
* Failure: UNKNOWN
*
* Programmer: Raymond Lu
* Nov 20, 2002
*
*-------------------------------------------------------------------------
*/
H5G_obj_t
H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
{
H5O_stab_t stab; /* Info about local heap & B-tree */
H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */
H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_get_type_by_idx, H5G_UNKNOWN)
/* Sanity check */
HDassert(oloc);
/* Get the B-tree & local heap info */
if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab, dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "unable to determine local heap address")
/* Set iteration information */
udata.common.f = oloc->file;
udata.common.idx = idx;
udata.common.num_objs = 0;
udata.common.op = H5G_stab_get_type_by_idx_cb;
udata.dxpl_id = dxpl_id;
udata.type = H5G_UNKNOWN;
/* Iterate over the group members */
if(H5B_iterate(oloc->file, dxpl_id, H5B_SNODE, H5G_node_by_idx, stab.btree_addr, &udata) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "iteration operator failed")
/* If we don't know the type now, we almost certainly went out of bounds */
if(udata.type == H5G_UNKNOWN)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "index out of bound")
/* Set the return value */
ret_value = udata.type;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_get_type_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -1478,6 +1478,7 @@ test_compat(hid_t fapl, hbool_t new_format)
hid_t group1_id = -1;
hid_t group2_id = -1;
H5G_stat_t sb_hard1, sb_hard2, sb_soft1;
H5G_obj_t obj_type; /* Object type */
hsize_t num_objs; /* Number of objects in a group */
char filename[1024];
char tmpstr[1024];
@ -1513,6 +1514,13 @@ test_compat(hid_t fapl, hbool_t new_format)
if(H5Gget_objname_by_idx(group1_id, (hsize_t)1, tmpstr, sizeof(tmpstr)) >= 0) TEST_ERROR
} H5E_END_TRY;
/* Test getting the type for objects */
if((obj_type = H5Gget_objtype_by_idx(group1_id, (hsize_t)0)) < 0) FAIL_STACK_ERROR
if(obj_type != H5G_GROUP) TEST_ERROR
H5E_BEGIN_TRY {
if(H5Gget_objtype_by_idx(group1_id, (hsize_t)1) >= 0) TEST_ERROR
} H5E_END_TRY;
/* Test getting the number of objects in a group */
if(H5Gget_num_objs(file_id, &num_objs) < 0) FAIL_STACK_ERROR
if(num_objs != 2) TEST_ERROR

View File

@ -1260,11 +1260,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
if(ginfo2.nlinks > 0) {
char objname[NAME_BUF_SIZE]; /* Name of object in group */
char objname2[NAME_BUF_SIZE]; /* Name of object in group */
H5G_obj_t objtype; /* Type of object in group */
H5G_obj_t objtype2; /* Type of object in group */
H5L_info_t linfo; /* Link information */
H5L_info_t linfo2; /* Link information */
hid_t oid, oid2; /* IDs of objects within group */
/* Loop over contents of groups */
for(idx = 0; idx < ginfo.nlinks; idx++) {
@ -1273,11 +1270,6 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
if(H5Lget_name_by_idx(gid2, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(HDstrcmp(objname, objname2)) TEST_ERROR
/* Check type of objects */
if((objtype = H5Gget_objtype_by_idx(gid, idx)) < 0) TEST_ERROR
if((objtype2 = H5Gget_objtype_by_idx(gid2, idx)) < 0) TEST_ERROR
if(objtype != objtype2) TEST_ERROR
/* Get link info */
if(H5Lget_info(gid, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_info(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) TEST_ERROR
@ -1285,8 +1277,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
/* Extra checks for "real" objects */
if(linfo.type == H5L_TYPE_HARD) {
H5O_info_t oinfo; /* Object info */
H5O_info_t oinfo2; /* Object info */
hid_t oid, oid2; /* IDs of objects within group */
H5O_info_t oinfo, oinfo2; /* Object info */
/* Compare some pieces of the object info */
if(H5Oget_info(gid, objname, &oinfo, H5P_DEFAULT) < 0) TEST_ERROR
@ -1312,83 +1304,59 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
continue;
else
addr_insert(&oinfo);
} /* end if */
/* Compare objects within group */
switch(objtype) {
case H5G_LINK:
{
char linkname[NAME_BUF_SIZE]; /* Link value */
char linkname2[NAME_BUF_SIZE]; /* Link value */
/* Open objects */
if((oid = H5Oopen(gid, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if((oid2 = H5Oopen(gid2, objname2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Check link values */
if(H5Lget_val(gid, objname, linkname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_val(gid2, objname2, linkname2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(HDstrcmp(linkname, linkname2)) TEST_ERROR
}
break;
/* Compare objects within group */
switch(oinfo.type) {
case H5O_TYPE_GROUP:
/* Compare groups */
if(compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) TEST_ERROR
break;
case H5G_GROUP:
/* Open groups */
if((oid = H5Gopen2(gid, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if((oid2 = H5Gopen2(gid2, objname2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
case H5O_TYPE_DATASET:
/* Compare datasets */
if(compare_datasets(oid, oid2, pid, NULL) != TRUE) TEST_ERROR
break;
/* Compare groups */
if(compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) TEST_ERROR
case H5O_TYPE_NAMED_DATATYPE:
/* Compare datatypes */
if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR
break;
/* Close groups */
if(H5Gclose(oid) < 0) TEST_ERROR
if(H5Gclose(oid2) < 0) TEST_ERROR
break;
case H5G_DATASET:
/* Open datasets */
if((oid = H5Dopen(gid, objname)) < 0) TEST_ERROR
if((oid2 = H5Dopen(gid2, objname2)) < 0) TEST_ERROR
/* Compare datasets */
if(compare_datasets(oid, oid2, pid, NULL) != TRUE) TEST_ERROR
/* Close datasets */
if(H5Dclose(oid) < 0) TEST_ERROR
if(H5Dclose(oid2) < 0) TEST_ERROR
break;
case H5G_TYPE:
/* Open datatypes */
if((oid = H5Topen(gid, objname)) < 0) TEST_ERROR
if((oid2 = H5Topen(gid2, objname2)) < 0) TEST_ERROR
/* Compare datatypes */
if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR
/* Close datatypes */
if(H5Tclose(oid) < 0) TEST_ERROR
if(H5Tclose(oid2) < 0) TEST_ERROR
break;
case H5G_UDLINK:
{
char linkval[NAME_BUF_SIZE]; /* Link value */
char linkval2[NAME_BUF_SIZE]; /* Link value */
/* Check that both links are the same type and the same size */
if(linfo.type != linfo2.type) TEST_ERROR
if(linfo.u.val_size != linfo2.u.val_size) TEST_ERROR
/* Get link udata */
if(H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
/* Compare link udata */
if(HDmemcmp(linkval, linkval2, linfo.u.val_size)) TEST_ERROR
}
break;
default:
default:
HDassert(0 && "Unknown type of object");
break;
} /* end switch */
break;
} /* end switch */
/* Close objects */
if(H5Oclose(oid) < 0) TEST_ERROR
if(H5Oclose(oid2) < 0) TEST_ERROR
} /* end if */
else {
/* Check that both links are the same size */
if(linfo.u.val_size != linfo2.u.val_size) TEST_ERROR
/* Compare link values */
if(linfo.type == H5L_TYPE_SOFT ||
(linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX)) {
char linkval[NAME_BUF_SIZE]; /* Link value */
char linkval2[NAME_BUF_SIZE]; /* Link value */
/* Get link values */
HDassert(linfo.u.val_size <= NAME_BUF_SIZE);
if(H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
/* Compare link data */
if(HDmemcmp(linkval, linkval2, linfo.u.val_size)) TEST_ERROR
} /* end else-if */
else {
HDassert(0 && "Unknown type of link");
} /* end else */
} /* end else */
} /* end for */
} /* end if */

View File

@ -167,9 +167,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
CHECK(ret, FAIL, "H5Dclose");
} /* end for */
/* Create a group and named datatype under root group for testing
* H5Gget_objtype_by_idx.
*/
/* Create a group and named datatype under root group for testing */
grp = H5Gcreate2(file, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Gcreate2");
@ -183,16 +181,16 @@ test_iter_group(hid_t fapl, hbool_t new_format)
CHECK(lnames[NDATASETS], NULL, "strdup");
/* Close everything up */
ret=H5Tclose(datatype);
ret = H5Tclose(datatype);
CHECK(ret, FAIL, "H5Tclose");
ret=H5Gclose(grp);
ret = H5Gclose(grp);
CHECK(ret, FAIL, "H5Gclose");
ret=H5Sclose(filespace);
ret = H5Sclose(filespace);
CHECK(ret, FAIL, "H5Sclose");
ret=H5Fclose(file);
ret = H5Fclose(file);
CHECK(ret, FAIL, "H5Fclose");
/* Sort the dataset names */
@ -203,7 +201,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
CHECK(file, FAIL, "H5Fopen");
/* These two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx, actually
/* These two functions, H5Oget_info_by_idx and H5Lget_name_by_idx, actually
* iterate through B-tree for group members in internal library design.
*/
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
@ -214,13 +212,13 @@ test_iter_group(hid_t fapl, hbool_t new_format)
VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info");
for(i = 0; i< (int)ginfo.nlinks; i++) {
H5G_obj_t obj_type; /* Type of object in file */
H5O_info_t oinfo; /* Object info */
ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lget_name_by_idx");
obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i);
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_idx");
} /* end for */
H5E_BEGIN_TRY {
@ -231,7 +229,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
ret = H5Gclose(root_group);
CHECK(ret, FAIL, "H5Gclose");
/* These two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx, actually
/* These two functions, H5Oget_info_by_idx and H5Lget_name_by_idx, actually
* iterate through B-tree for group members in internal library design.
* (Same as test above, but with the file ID instead of opening the root group)
*/
@ -240,14 +238,14 @@ test_iter_group(hid_t fapl, hbool_t new_format)
VERIFY(ginfo.nlinks, NDATASETS + 2, "H5Gget_info");
for(i = 0; i< (int)ginfo.nlinks; i++) {
H5G_obj_t obj_type; /* Type of object in file */
H5O_info_t oinfo; /* Object info */
ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lget_name_by_idx");
obj_type = H5Gget_objtype_by_idx(file, (hsize_t)i);
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
}
ret = H5Oget_info_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_idx");
} /* end for */
H5E_BEGIN_TRY {
ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS + 3), dataset_name, (size_t)NAMELEN, H5P_DEFAULT);
@ -733,9 +731,7 @@ static void test_grp_memb_funcs(hid_t fapl)
CHECK(ret, FAIL, "H5Dclose");
} /* end for */
/* Create a group and named datatype under root group for testing
* H5Gget_objtype_by_idx.
*/
/* Create a group and named datatype under root group for testing */
grp = H5Gcreate2(file, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Gcreate2");
@ -768,7 +764,7 @@ static void test_grp_memb_funcs(hid_t fapl)
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
CHECK(file, FAIL, "H5Fopen");
/* These two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx, actually
/* These two functions, H5Oget_info_by_idx and H5Lget_name_by_idx, actually
* iterate through B-tree for group members in internal library design.
*/
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
@ -778,8 +774,8 @@ static void test_grp_memb_funcs(hid_t fapl)
CHECK(ret, FAIL, "H5Gget_info");
VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info");
for(i=0; i< (int)ginfo.nlinks; i++) {
H5G_obj_t obj_type; /* Type of object in file */
for(i = 0; i < (int)ginfo.nlinks; i++) {
H5O_info_t oinfo; /* Object info */
/* Test with NULL for name, to query length */
name_len = H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, NULL, (size_t)NAMELEN, H5P_DEFAULT);
@ -795,15 +791,15 @@ static void test_grp_memb_funcs(hid_t fapl)
obj_names[i] = HDstrdup(dataset_name);
CHECK(obj_names[i], NULL, "strdup");
obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i);
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_idx");
if(!HDstrcmp(dataset_name, "grp"))
VERIFY(obj_type, H5G_GROUP, "H5Lget_name_by_idx");
VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx");
if(!HDstrcmp(dataset_name, "dtype"))
VERIFY(obj_type, H5G_TYPE, "H5Lget_name_by_idx");
VERIFY(oinfo.type, H5O_TYPE_NAMED_DATATYPE, "H5Lget_name_by_idx");
if(!HDstrncmp(dataset_name, "Dataset", (size_t)7))
VERIFY(obj_type, H5G_DATASET, "H5Lget_name_by_idx");
VERIFY(oinfo.type, H5O_TYPE_DATASET, "H5Lget_name_by_idx");
} /* end for */
H5E_BEGIN_TRY {
@ -845,7 +841,6 @@ static void test_links(hid_t fapl)
char obj_name[NAMELEN]; /* Names of the object in group */
ssize_t name_len; /* Length of object's name */
hid_t gid, gid1;
H5G_obj_t obj_type; /* Type of object */
H5G_info_t ginfo; /* Buffer for querying object's info */
hsize_t i;
herr_t ret; /* Generic return value */
@ -875,24 +870,34 @@ static void test_links(hid_t fapl)
CHECK(ret, FAIL, "H5Gget_info");
VERIFY(ginfo.nlinks, 3, "H5Gget_info");
/* Test these two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx */
/* Test these two functions, H5Oget_info_by_idx and H5Lget_name_by_idx */
for(i = 0; i < ginfo.nlinks; i++) {
/* Get object name */
H5O_info_t oinfo; /* Object info */
H5L_info_t linfo; /* Link info */
/* Get link name */
name_len = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, i, obj_name, (size_t)NAMELEN, H5P_DEFAULT);
CHECK(name_len, FAIL, "H5Lget_name_by_idx");
obj_type = H5Gget_objtype_by_idx(gid, i);
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
/* Get link type */
ret = H5Lget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &linfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lget_info_by_idx");
/* Get object type */
if(linfo.type == H5L_TYPE_HARD) {
ret = H5Oget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_idx");
} /* end if */
if(!HDstrcmp(obj_name, "g1.1"))
VERIFY(obj_type, H5G_GROUP, "H5Lget_name_by_idx");
VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx");
else if(!HDstrcmp(obj_name, "hardlink"))
VERIFY(obj_type, H5G_GROUP, "H5Lget_name_by_idx");
VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx");
else if(!HDstrcmp(obj_name, "softlink"))
VERIFY(obj_type, H5G_LINK, "H5Lget_name_by_idx");
VERIFY(linfo.type, H5L_TYPE_SOFT, "H5Lget_name_by_idx");
else
CHECK(0, 0, "unknown object name");
}
} /* end for */
ret = H5Gclose(gid);
CHECK(ret, FAIL, "H5Gclose");

View File

@ -937,7 +937,7 @@ test_reference_obj_deleted(void)
**
****************************************************************/
static herr_t
test_deref_iter_op(hid_t UNUSED group, const char *name, const H5L_info_t *info,
test_deref_iter_op(hid_t UNUSED group, const char *name, const H5L_info_t UNUSED *info,
void *op_data)
{
int *count = (int *)op_data; /* Pointer to name counter */
@ -987,7 +987,7 @@ test_reference_group(void)
hobj_ref_t rref; /* Reference to read */
H5G_info_t ginfo; /* Group info struct */
char objname[NAME_SIZE]; /* Buffer to store name */
H5G_obj_t objtype; /* Object type */
H5O_info_t oinfo; /* Object info struct */
int count = 0; /* Count within iterated group */
herr_t ret;
@ -1073,8 +1073,9 @@ test_reference_group(void)
CHECK(ret, FAIL, "H5Lget_name_by_idx");
VERIFY_STR(objname, DSETNAME2, "H5Lget_name_by_idx");
objtype = H5Gget_objtype_by_idx(gid, (hsize_t)0);
VERIFY(objtype, H5G_DATASET, "H5Gget_objtype_by_idx");
ret = H5Oget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &oinfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_idx");
VERIFY(oinfo.type, H5O_TYPE_DATASET, "H5Oget_info_by_idx");
/* Unlink one of the objects in the dereferenced group */
ret = H5Ldelete(gid, GROUPNAME2, H5P_DEFAULT);