diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-03-24 23:18:34 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-03-24 23:18:34 (GMT) |
commit | e987de2c42628f94e713111c5cbb09bbd3db4a68 (patch) | |
tree | 4baf097e2a0480c9cf24e2ce28749f969afb8fd8 /src/h5ls.c | |
parent | 2ed9aa69f74cc2002fb9a03c8893056a1daea1db (diff) | |
download | hdf5-e987de2c42628f94e713111c5cbb09bbd3db4a68.zip hdf5-e987de2c42628f94e713111c5cbb09bbd3db4a68.tar.gz hdf5-e987de2c42628f94e713111c5cbb09bbd3db4a68.tar.bz2 |
[svn-r329] Changes since 19980324
----------------------
./src/H5D.c
Zero element requests for H5Dread() and H5Dwrite() succeed.
./src/H5F.c
./src/H5Fprivate.h
All files will have a root group. This greatly simplifies the
library at the expense of ~1k extra bytes in files that have
only one object.
./src/H5D.c
./src/H5Dprivate.h
./html/Groups.html
Functions that used to take a file ID and an object name can
now take a group ID instead of a file ID. This doesn't change
the API, only it's documentation.
./src/H5G.c
./src/H5Gprivate.h
./src/H5O.c
./src/H5Oprivate.h
Removed extra file arguments from some internal functions
since the file pointer can be found from the group pointer or
a symbol table entry (ent->file or H5G_fileof(group)).
Besides, when we eventually implement mounting one file on
another, H5G_namei() might return a different file than what
you gave it, and that file is part of the returned symbol
table entry.
./src/H5G.c
Fixed bug with `.' appearing in a name. It used to hang the
library.
./src/Makefile.in
./src/h5ls.c [NEW]
./MANIFEST
Added `h5ls' a simple program that takes a file name and a
directory and lists the contents of that directory using
H5Giterate().
./test/istore.c
Changed an argument to H5G_create().
./test/tstab.c
Removed test_1 which was testing that files with a single
object don't have a root group. This no longer applies.
Diffstat (limited to 'src/h5ls.c')
-rw-r--r-- | src/h5ls.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/h5ls.c b/src/h5ls.c new file mode 100644 index 0000000..e8ac70c --- /dev/null +++ b/src/h5ls.c @@ -0,0 +1,102 @@ +/* + * Copyright (C) 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke <matzke@llnl.gov> + * Monday, March 23, 1998 + */ +#include <assert.h> +#include <hdf5.h> +#include <stdio.h> +#include <stdlib.h> + + + +/*------------------------------------------------------------------------- + * Function: list + * + * Purpose: Prints the group member name. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Monday, March 23, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +list (hid_t group, const char *name, void *op_data) +{ + hid_t obj; + hid_t (*func)(void*); + void *edata; + int i; + + /* Disable error reporting */ + H5Eget_auto (&func, &edata); + H5Eset_auto (NULL, NULL); + + /* Print info about each name */ + printf ("%-30s", name); + if ((obj=H5Dopen (group, name))>=0) { + size_t size[64]; + hid_t space = H5Dget_space (obj); + int ndims = H5Sget_dims (space, size); + printf (" Dataset {"); + for (i=0; i<ndims; i++) { + printf ("%s%lu", i?", ":"", (unsigned long)size[i]); + } + printf ("}\n"); + H5Dclose (space); + H5Dclose (obj); + } else if ((obj=H5Gopen (group, name))>=0) { + printf (" Group\n"); + H5Gclose (obj); + } else { + printf (" Unknown Type\n"); + } + + /* Restore error reporting */ + H5Eset_auto (func, edata); + return 0; +} + + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Opens a file and lists the specified group + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Robb Matzke + * Monday, March 23, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main (int argc, char *argv[]) +{ + hid_t file; + herr_t status; + + assert (3==argc); + + file = H5Fopen (argv[1], H5F_ACC_RDONLY, H5P_DEFAULT); + assert (file>=0); + + status = H5Giterate (file, argv[2], NULL, list, NULL); + assert (status>=0); + + H5Fclose (file); + return 0; +} |