diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2008-09-21 18:36:09 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2008-09-21 18:36:09 (GMT) |
commit | 13f5dbc05db6d5a4c3bc6057ebb0a1c44a1a2410 (patch) | |
tree | f1dfd9dd5b850d15184728b9437bcec608d4f9b8 /tools/lib/h5trav.c | |
parent | 50f38c5e597a6234f95e757a7d61d227bcf0fe0d (diff) | |
download | hdf5-13f5dbc05db6d5a4c3bc6057ebb0a1c44a1a2410.zip hdf5-13f5dbc05db6d5a4c3bc6057ebb0a1c44a1a2410.tar.gz hdf5-13f5dbc05db6d5a4c3bc6057ebb0a1c44a1a2410.tar.bz2 |
[svn-r15669] Purpose: Add feature requested in bug #1282
Description: Adds capability to h5ls to traverse external links when the -r
(recursive) option is given. Changes to the way absolute path names are patched
in h5trav.c. Changes to the way recursive traversal starting from a non-root
group is handled (which also fixes some preexisting issues). Tests added for
these cases.
Tested: kagiso, smirom, linew (h5committest)
Diffstat (limited to 'tools/lib/h5trav.c')
-rw-r--r-- | tools/lib/h5trav.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index bb8014d..69b4512 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -40,6 +40,8 @@ typedef struct { trav_addr_t *seen; /* List of addresses seen already */ const trav_visitor_t *visitor; /* Information for visiting each link/object */ hbool_t is_absolute; /* Whether the traversal has absolute paths */ + const char *base_grp_name; /* Name of the group that serves as the base + * for iteration */ } trav_ud_traverse_t; typedef struct { @@ -146,9 +148,15 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, /* Create the full path name for the link */ if(udata->is_absolute) { - new_name = HDmalloc(HDstrlen(path) + 2); - *new_name = '/'; - HDstrcpy(new_name + 1, path); + size_t base_len = HDstrlen(udata->base_grp_name); + size_t add_slash = base_len ? ((udata->base_grp_name)[base_len-1] != '/') : 1; + + if(NULL == (new_name = HDmalloc(base_len + add_slash + HDstrlen(path) + 1))) + return(H5_ITER_ERROR); + HDstrcpy(new_name, udata->base_grp_name); + if (add_slash) + new_name[base_len] = '/'; + HDstrcpy(new_name + base_len + add_slash, path); full_name = new_name; } /* end if */ else @@ -242,6 +250,7 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, udata.seen = &seen; udata.visitor = visitor; udata.is_absolute = (*grp_name == '/'); + udata.base_grp_name = grp_name; /* Check for iteration of links vs. visiting all links recursively */ if(recurse) { |