summaryrefslogtreecommitdiffstats
path: root/src/H5Gstab.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-12 11:56:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-12 11:56:10 (GMT)
commit2355d25955756f689f68bc6d8681116e2a41a5a6 (patch)
tree8a5e09861fa00672fed1a438f3874d44ed48cd4a /src/H5Gstab.c
parentb1c6bb5b982562a872f79f58d003fae65af2a2a4 (diff)
downloadhdf5-2355d25955756f689f68bc6d8681116e2a41a5a6.zip
hdf5-2355d25955756f689f68bc6d8681116e2a41a5a6.tar.gz
hdf5-2355d25955756f689f68bc6d8681116e2a41a5a6.tar.bz2
[svn-r12894] Description:
Add H5Lget_name_by_idx routine & tests Move more H5G routines to deprecated API file Tested on: FreeBSD/32 4.11 (sleipnir) w/threadsafe Linux/32 2.4 (heping) C++ & FORTRAN Linux/64 2.4 (mir) w/build-all & enable_compat1.6 AIX/32 5.? (copper) w/parallel & FORTRAN
Diffstat (limited to 'src/H5Gstab.c')
-rw-r--r--src/H5Gstab.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index b6796eb..4a0d46a 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -530,8 +530,8 @@ done:
*-------------------------------------------------------------------------
*/
ssize_t
-H5G_stab_get_name_by_idx(H5O_loc_t *oloc, hsize_t idx, char* name,
- size_t size, hid_t dxpl_id)
+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)
{
H5O_stab_t stab; /* Info about local heap & B-tree */
H5G_bt_it_idx1_t udata; /* Iteration information */
@@ -546,10 +546,22 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, hsize_t idx, char* name,
if(NULL == H5O_read(oloc, H5O_STAB_ID, 0, &stab, dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address")
+ /* Remap index for decreasing iteration order */
+ if(order == H5_ITER_DEC) {
+ hsize_t nlinks = 0; /* Number of links in group */
+
+ /* Iterate over the symbol table nodes, to count the links */
+ if(H5B_iterate(oloc->file, dxpl_id, H5B_SNODE, H5G_node_sumup, stab.btree_addr, &nlinks) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed")
+
+ /* Map decreasing iteration order index to increasing iteration order index */
+ n = nlinks - (n + 1);
+ } /* end if */
+
/* Set iteration information */
udata.common.f = oloc->file;
udata.common.dxpl_id = dxpl_id;
- udata.common.idx = idx;
+ udata.common.idx = n;
udata.common.num_objs = 0;
udata.common.op = H5G_stab_get_name_by_idx_cb;
udata.heap_addr = stab.heap_addr;
@@ -568,7 +580,7 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, hsize_t idx, char* name,
/* Copy the name into the user's buffer, if given */
if(name) {
- HDstrncpy(name, udata.name, MIN((size_t)(ret_value + 1),size));
+ HDstrncpy(name, udata.name, MIN((size_t)(ret_value + 1), size));
if((size_t)ret_value >= size)
name[size - 1]='\0';
} /* end if */
@@ -884,7 +896,7 @@ H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n,
/* Iterate over the symbol table nodes, to count the links */
if(H5B_iterate(grp_oloc->file, dxpl_id, H5B_SNODE, H5G_node_sumup, stab.btree_addr, &nlinks) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed")
/* Map decreasing iteration order index to increasing iteration order index */
n = nlinks - (n + 1);