From 5dc417886b5bb36b43d9354672cfc9e2a2b29512 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 16 Dec 2009 22:37:19 -0800 Subject: Walk HDF groups to display a menu and switch image --- src/hdf5-file.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/hdf5-file.c') diff --git a/src/hdf5-file.c b/src/hdf5-file.c index ea3b91f7..0d211998 100644 --- a/src/hdf5-file.c +++ b/src/hdf5-file.c @@ -248,3 +248,57 @@ int hdf5_read(struct hdfile *f, struct image *image) return 0; } + + +char **hdfile_walk_tree(struct hdfile *f, int *n, const char *parent, + int **p_is_group, int **p_is_image) +{ + hid_t gh; + hsize_t num; + char **res; + int i; + int *is_group; + int *is_image; + + gh = H5Gopen(f->fh, parent, H5P_DEFAULT); + if ( gh < 0 ) { + *n = 0; + return NULL; + } + + if ( H5Gget_num_objs(gh, &num) < 0 ) { + /* Whoopsie */ + *n = 0; + return NULL; + } + *n = num; + if ( num == 0 ) return NULL; /* Bail out now */ + + res = malloc(num*sizeof(char *)); + is_image = malloc(num*sizeof(int)); + is_group = malloc(num*sizeof(int)); + *p_is_image = is_image; + *p_is_group = is_group; + + for ( i=0; i