summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBill Wendling <wendling@ncsa.uiuc.edu>2002-01-06 02:18:20 (GMT)
committerBill Wendling <wendling@ncsa.uiuc.edu>2002-01-06 02:18:20 (GMT)
commit8c1c416d4d0e948befe5436a34c11f2c86bcc745 (patch)
tree02ed773da77bf6cf628072d8d09c361cd386fbf8 /tools
parent84dc43d3136c423ee774c0f73515d9faecef0156 (diff)
downloadhdf5-8c1c416d4d0e948befe5436a34c11f2c86bcc745.zip
hdf5-8c1c416d4d0e948befe5436a34c11f2c86bcc745.tar.gz
hdf5-8c1c416d4d0e948befe5436a34c11f2c86bcc745.tar.bz2
[svn-r4784]
Purpose: feature add Description: Added ability to h5dumper to dump Group comments. Solution: Stole the code from h5ls that does this and put it into the h5dumper code. Modified the DDL to reflect the newest change. Added a testcase (tgrp_comments.*) to test that it's actually doing the comments correctly. Small modification to H5G.c. The error comment should have said that it couldn't "get" the comment instead of "set" the comment... Platforms tested: Dangermouse, Kelgai, Modi4
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c10
-rw-r--r--tools/h5dump/h5dumptst.c60
-rwxr-xr-xtools/h5dump/testh5dump.sh3
3 files changed, 72 insertions, 1 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 282c723..6e4db4d 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -1564,7 +1564,7 @@ dump_group(hid_t gid, const char *name)
{
H5G_stat_t statbuf;
hid_t dset, type;
- char typename[1024], *tmp;
+ char typename[1024], *tmp, comment[50];
int i, xtype = H5G_UNKNOWN; /* dump all */
tmp = malloc(strlen(prefix) + strlen(name) + 2);
@@ -1577,6 +1577,14 @@ dump_group(hid_t gid, const char *name)
if (display_oid)
dump_oid(gid);
+ comment[0] = '\0';
+ H5Gget_comment(gid, ".", sizeof(comment), comment);
+
+ if (comment[0]) {
+ indentation(indent);
+ printf("COMMENT \"%s\"\n", comment);
+ }
+
if (!strcmp(name, "/") && unamedtype)
/* dump unamed type in root group */
for (i = 0; i < type_table->nobjs; i++)
diff --git a/tools/h5dump/h5dumptst.c b/tools/h5dump/h5dumptst.c
index 5fd2e17..e9dda05 100644
--- a/tools/h5dump/h5dumptst.c
+++ b/tools/h5dump/h5dumptst.c
@@ -44,6 +44,7 @@
#define FILE30 "tarray6.h5"
#define FILE31 "tarray7.h5"
#define FILE32 "tempty.h5"
+#define FILE33 "tgrp_comments.h5"
#define LENSTR 50
#define LENSTR2 11
@@ -2529,6 +2530,64 @@ static void test_empty(void)
ret = H5Fclose(file);
}
+static void test_group_comments(void)
+{
+ hid_t fid, group;
+
+ fid = H5Fcreate(FILE33, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* / */
+ group = H5Gcreate (fid, "/g1", 0);
+ H5Gset_comment(group, "/g1", "Comment for group /g1");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g2", 0);
+ H5Gset_comment(group, "/g2", "Comment for group /g2");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g3", 0);
+ H5Gset_comment(group, "/g3", "Comment for group /g3");
+ H5Gclose(group);
+
+ /* /g1 */
+ group = H5Gcreate (fid, "/g1/g1.1", 0);
+ H5Gset_comment(group, "/g1/g1.1", "Comment for group /g1/g1.1");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g1/g1.2", 0);
+ H5Gset_comment(group, "/g1/g1.2", "Comment for group /g1/g1.2");
+ H5Gclose(group);
+
+ /* /g2 */
+ group = H5Gcreate (fid, "/g2/g2.1", 0);
+ H5Gset_comment(group, "/g2/g2.1", "Comment for group /g2/g2.1");
+ H5Gclose(group);
+
+ /* /g3 */
+ group = H5Gcreate (fid, "/g3/g3.1", 0);
+ H5Gset_comment(group, "/g3/g3.1", "Comment for group /g3/g3.1");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g3/g3.2", 0);
+ H5Gset_comment(group, "/g3/g3.2", "Comment for group /g3/g3.2");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g3/g3.3", 0);
+ H5Gset_comment(group, "/g3/g3.3", "Comment for group /g3/g3.3");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g3/g3.4", 0);
+ H5Gset_comment(group, "/g3/g3.4", "Comment for group /g3/g3.4");
+ H5Gclose(group);
+
+ /* /g2/g2.1 */
+ group = H5Gcreate (fid, "/g2/g2.1/g2.1.1", 0);
+ H5Gset_comment(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g2/g2.1/g2.1.2", 0);
+ H5Gset_comment(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2");
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g2/g2.1/g2.1.3", 0);
+ H5Gset_comment(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3");
+ H5Gclose(group);
+
+ H5Fclose(fid);
+}
+
int main(void)
{
test_group();
@@ -2573,6 +2632,7 @@ int main(void)
test_array7();
test_empty();
+ test_group_comments();
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh b/tools/h5dump/testh5dump.sh
index 55d86fc..4776ce3 100755
--- a/tools/h5dump/testh5dump.sh
+++ b/tools/h5dump/testh5dump.sh
@@ -147,6 +147,9 @@ TOOLTEST tarray7.ddl tarray7.h5
# test for files with empty data
TOOLTEST tempty.ddl tempty.h5
+# test for files with groups that have comments
+TOOLTEST tgrp_comments.ddl tgrp_comments.h5
+
# test XML
TOOLTEST tall.h5.xml --xml tall.h5
TOOLTEST tattr.h5.xml --xml tattr.h5