summaryrefslogtreecommitdiffstats
path: root/src/H5Gloc.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-21 01:49:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-21 01:49:55 (GMT)
commit036e799cf9efb1a8da3bf9ce7287177888ca9556 (patch)
treebe6e262bde93039c97c0f968c404db4a1c287354 /src/H5Gloc.c
parentf6deaca1d4cca061273cd6daef0357200d4c6ea4 (diff)
downloadhdf5-036e799cf9efb1a8da3bf9ce7287177888ca9556.zip
hdf5-036e799cf9efb1a8da3bf9ce7287177888ca9556.tar.gz
hdf5-036e799cf9efb1a8da3bf9ce7287177888ca9556.tar.bz2
[svn-r12955] Description:
Finish implementing H5Oopen_by_idx() (still needs tests) Tested on: Linux/32 2.4 (chicago) Linux/64 2.4 (chicago2)
Diffstat (limited to 'src/H5Gloc.c')
-rw-r--r--src/H5Gloc.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/H5Gloc.c b/src/H5Gloc.c
index ca488cf..89f2861 100644
--- a/src/H5Gloc.c
+++ b/src/H5Gloc.c
@@ -58,6 +58,7 @@ typedef struct {
/* User data for looking up an object in a group by index */
typedef struct {
/* downward */
+ hid_t lapl_id; /* LAPL to use for operation */
hid_t dxpl_id; /* DXPL to use for operation */
H5L_index_t idx_type; /* Index to use */
H5_iter_order_t order; /* Iteration order within index */
@@ -414,6 +415,8 @@ H5G_loc_find_by_idx_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name,
H5G_loc_fbi_t *udata = (H5G_loc_fbi_t *)_udata; /* User data passed in */
H5O_link_t fnd_lnk; /* Link within group */
hbool_t lnk_copied = FALSE; /* Whether the link was copied */
+ size_t links_left = 1; /* # of links left to traverse (somewhat bogus... :-/ ) */
+ hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_loc_find_by_idx_cb)
@@ -428,13 +431,27 @@ H5G_loc_find_by_idx_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name,
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "link not found")
lnk_copied = TRUE;
- /* Build the object location for the link */
+ /* Build the initial object location for the link */
+ if(H5G_link_to_loc(obj_loc, &fnd_lnk, udata->loc) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot initialize object location")
+ obj_loc_valid = TRUE;
+
+ /* Perform any special traversals that the link needs */
+ /* (soft links, user-defined links, file mounting, etc.) */
+ /* (may modify the object location) */
+ if(H5G_traverse_special(obj_loc, &fnd_lnk, H5G_TARGET_NORMAL, &links_left, TRUE, udata->loc, udata->lapl_id, udata->dxpl_id) < 0)
+ HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "special link traversal failed")
done:
/* Reset the link information, if we have a copy */
if(lnk_copied)
H5O_reset(H5O_LINK_ID, &fnd_lnk);
+ /* Release the object location if we failed after copying it */
+ if(ret_value < 0 && obj_loc_valid)
+ if(H5G_loc_free(udata->loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
+
/* Indicate that this callback didn't take ownership of the group *
* location for the object */
*own_loc = H5G_OWN_NONE;
@@ -472,6 +489,7 @@ H5G_loc_find_by_idx(H5G_loc_t *loc, const char *group_name, H5L_index_t idx_type
/* Set up user data for locating object */
udata.dxpl_id = dxpl_id;
+ udata.lapl_id = lapl_id;
udata.idx_type = idx_type;
udata.order = order;
udata.n = n;