diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-06-04 00:17:27 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-06-04 00:17:27 (GMT) |
commit | b75540244fb313f179fe11c587e5e008677e6762 (patch) | |
tree | b47e892c9d3bf61ff544169df1c7a3489f8b3a14 /tools/h5ls | |
parent | 771bae88881f4ae8102c9553fd10e0938aa3094c (diff) | |
download | hdf5-b75540244fb313f179fe11c587e5e008677e6762.zip hdf5-b75540244fb313f179fe11c587e5e008677e6762.tar.gz hdf5-b75540244fb313f179fe11c587e5e008677e6762.tar.bz2 |
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like
"h5ls foo.h5/bar") from working correctly.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.5.3 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'tools/h5ls')
-rw-r--r-- | tools/h5ls/h5ls.c | 35 | ||||
-rwxr-xr-x | tools/h5ls/testh5ls.sh | 1 |
2 files changed, 26 insertions, 10 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 80b45d8..6f07050 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -33,8 +33,8 @@ /* Struct to pass through to visitors */ typedef struct { - hid_t fid; /* File ID */ const char *fname; /* Filename */ + hid_t gid; /* Group ID */ }iter_t; /* Command-line switches */ @@ -1687,7 +1687,7 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void /* Open the object. Not all objects can be opened. If this is the case * then return right away. */ - if(obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) { + if(obj_type >= 0 && (obj = H5Oopen(iter->gid, name, H5P_DEFAULT)) < 0) { printf(" *ERROR*\n"); goto done; } /* end if */ @@ -1779,7 +1779,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) if((buf = HDmalloc(linfo->u.val_size)) == NULL) goto done; - if(H5Lget_val(iter->fid, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) { + if(H5Lget_val(iter->gid, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) { HDfree(buf); goto done; } /* end if */ @@ -1796,7 +1796,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) if((buf = HDmalloc(linfo->u.val_size)) == NULL) goto done; - if(H5Lget_val(iter->fid, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) { + if(H5Lget_val(iter->gid, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) { HDfree(buf); goto done; } /* end if */ @@ -2164,7 +2164,7 @@ main(int argc, const char *argv[]) /* Shorten the file name; lengthen the object name */ x = oname; - oname = strrchr(fname, '/'); + oname = HDstrrchr(fname, '/'); if(x) *x = '/'; if(!oname) @@ -2185,7 +2185,7 @@ main(int argc, const char *argv[]) /* Remember the file information for later */ iter.fname = fname; - iter.fid = file; + iter.gid = -1; /* Check for root group as object name */ if(HDstrcmp(oname, root_name)) { @@ -2209,13 +2209,28 @@ main(int argc, const char *argv[]) } /* end if */ /* Check for group iteration */ - if(H5O_TYPE_GROUP == oi.type && !grp_literal_g) + if(H5O_TYPE_GROUP == oi.type && !grp_literal_g) { + /* Get ID for group */ + if((iter.gid = H5Gopen2(file, oname, H5P_DEFAULT)) < 0) { + fprintf(stderr, "%s: unable to open '%s' as group\n", fname, oname); + continue; + } /* end if */ + /* Specified name is a group. List the complete contents of the group. */ h5trav_visit(file, oname, display_root_g, recursive_g, list_obj, list_lnk, &iter); - else + + /* Close group */ + H5Gclose(iter.gid); + } /* end if */ + else { + /* Use file ID for root group ID */ + iter.gid = file; + /* Specified name is a non-group object -- list that object */ list_obj(oname, &oi, NULL, &iter); - } else + } /* end else */ + } /* end if */ + else /* Specified name is not for object -- list that link */ list_lnk(oname, &li, &iter); H5Fclose(file); @@ -2223,5 +2238,5 @@ main(int argc, const char *argv[]) } /* end while */ leave(0); -} +} /* end main() */ diff --git a/tools/h5ls/testh5ls.sh b/tools/h5ls/testh5ls.sh index cef5730..6383709 100755 --- a/tools/h5ls/testh5ls.sh +++ b/tools/h5ls/testh5ls.sh @@ -113,6 +113,7 @@ TOOLTEST help-3.ls 0 -w80 -? TOOLTEST tall-1.ls 0 -w80 tall.h5 TOOLTEST tall-2.ls 0 -w80 -r -d tall.h5 TOOLTEST tgroup.ls 0 -w80 tgroup.h5 +TOOLTEST tgroup-3.ls 0 -w80 tgroup.h5/g1 # test for displaying groups # The following combination of arguments is expected to return an error message |