diff options
author | Robb Matzke <matzke@llnl.gov> | 1999-08-24 12:52:10 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1999-08-24 12:52:10 (GMT) |
commit | 296d9cf76640fa1aab51479def07119236f86cb9 (patch) | |
tree | fed33399626284a57091730a748309d709edb13a /tools/h5ls.c | |
parent | 8e338a50298bbd928e919cd2dbd30e57e8b322ce (diff) | |
download | hdf5-296d9cf76640fa1aab51479def07119236f86cb9.zip hdf5-296d9cf76640fa1aab51479def07119236f86cb9.tar.gz hdf5-296d9cf76640fa1aab51479def07119236f86cb9.tar.bz2 |
[svn-r1585] Changes since 19990820
----------------------
./src/H5D.c
Added additional elements to a variable initializer in
H5Dvlen_get_buf_size() to shut up a warning message. Also
added the API tracing call.
./src/H5F.c
Added file opening optimizations. If the driver doesn't
support the ability to determine when two file handles refer
to the same file (like MPIO and GASS) then H5F_open() makes
fewer calls to the driver's open callback. Also, if the
tentative file access flags are the same as the original flags
then H5F_open() makes fewer calls to the file device.
./src/H5FD.c
./src/H5FDprivate.h
./src/H5FDpublic.h
Added H5FD_get_class() so the library can get information
about what file driver callbacks are defined. This will be
useful when more optimization functions are added to the VFL,
such as for MPIO derived datatype I/O.
./src/H5FDcore.c
./src/H5FDfamily.c
./src/H5FDmpio.c
./src/H5FDmulti.c
./src/H5FDsec2.c
The driver symbols (like H5FD_CORE, etc) are actually function
calls. The functions were fixed to return correct values even
after calling H5close().
./src/H5FDmulti.c
./src/H5FDmulti.h
Added support for opening a file when parts are missing (only
if the caller explicitly allows that in the file access
property list).
Moved some common code sequences into macros or functions.
Added better support for reopening files. All the application
has to know is that the file is a multi file and the base name
from which all the member names are created.
More debugging output when the file is opened with the
H5F_ACC_DEBUG flag.
Fixed various bugs.
./src/H5Fistore.c
Chunked raw data was accidently allocated as meta data instead
of raw data.
./src/H5I.c
The H5Iget_type() function fails when invoked with an old
object ID (an ID which has been closed down).
./test/h5test.c
Added an extra argument when setting the multi file access
property lists so the test fails if it can't open one of the
sub-files.
./tools/h5ls.c
Improved the algorithm for deciding what file driver to
use. It basically tries all of the predefined drivers and is
now able to open family, split, and multi files without
looking for special characters in the file name.
Added `-e' and `--errors' switches which cause errors from
libhdf5 to be reported on stderr in addition to the simple
error message displayed by h5ls.
Diffstat (limited to 'tools/h5ls.c')
-rw-r--r-- | tools/h5ls.c | 79 |
1 files changed, 61 insertions, 18 deletions
diff --git a/tools/h5ls.c b/tools/h5ls.c index a77d413..bf5e7eb 100644 --- a/tools/h5ls.c +++ b/tools/h5ls.c @@ -18,7 +18,10 @@ /* * File drivers */ +#include <H5FDsec2.h> +#include <H5FDmulti.h> #include <H5FDfamily.h> +#define NDRIVERS 10 /* * If defined then include the file name as part of the object name when @@ -37,6 +40,7 @@ static hbool_t fullname_g = FALSE; /*print full path names */ static hbool_t recursive_g = FALSE; /*recursive descent listing */ static hbool_t grp_literal_g = FALSE; /*list group, not contents */ static hbool_t hexdump_g = FALSE; /*show data as raw hexadecimal */ +static hbool_t show_errors_g = FALSE; /*print HDF5 error messages */ /* Info to pass to the iteration functions */ typedef struct iter_t { @@ -98,6 +102,7 @@ usage: %s [OPTIONS] [OBJECTS...]\n\ -h, -?, --help Print a usage message and exit\n\ -a, --address Print addresses for raw data\n\ -d, --data Print the values of datasets\n\ + -e, --errors Show all HDF5 error reporting\n\ -f, --full Print full path names instead of base names\n\ -g, --group Show information about a group, not its contents\n\ -l, --label Label members of compound datasets\n\ @@ -1855,18 +1860,22 @@ get_width(void) int main (int argc, char *argv[]) { - hid_t file=-1, plist=-1, root=-1; + hid_t file=-1, root=-1, fapl=-1; char *fname=NULL, *oname=NULL, *x; const char *progname; const char *s = NULL; char *rest, *container=NULL; - int argno; + int argno, dno; H5G_stat_t sb; iter_t iter; static char root_name[] = "/"; - /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ - H5Eset_auto(NULL, NULL); + int ndrivers=0; + struct { + const char *name; + hid_t fapl; + } driver[NDRIVERS]; + /* Build display table */ DISPATCH(H5G_DATASET, "Dataset", H5Dopen, H5Dclose, @@ -1901,12 +1910,14 @@ main (int argc, char *argv[]) exit(0); } else if (!strcmp(argv[argno], "--address")) { address_g = TRUE; - } else if (!strcmp(argv[argno], "--group")) { - grp_literal_g = TRUE; } else if (!strcmp(argv[argno], "--data")) { data_g = TRUE; + } else if (!strcmp(argv[argno], "--errors")) { + show_errors_g = TRUE; } else if (!strcmp(argv[argno], "--full")) { fullname_g = TRUE; + } else if (!strcmp(argv[argno], "--group")) { + grp_literal_g = TRUE; } else if (!strcmp(argv[argno], "--label")) { label_g = TRUE; } else if (!strcmp(argv[argno], "--recursive")) { @@ -1968,6 +1979,9 @@ main (int argc, char *argv[]) case 'd': /* --data */ data_g = TRUE; break; + case 'e': /* --errors */ + show_errors_g = TRUE; + break; case 'f': /* --full */ fullname_g = TRUE; break; @@ -2014,6 +2028,34 @@ main (int argc, char *argv[]) usage(progname); exit(1); } + + /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ + if (!show_errors_g) H5Eset_auto(NULL, NULL); + + /* + * Build a list of file access property lists which we should try when + * opening the file. Eventually we'd like some way for the user to + * augment/replace this list interactively. + */ + + driver[ndrivers].name = "sec2"; + driver[ndrivers].fapl = H5P_DEFAULT; + ndrivers++; + + driver[ndrivers].name = "family"; + driver[ndrivers].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_family(fapl, 0, H5P_DEFAULT); + ndrivers++; + + driver[ndrivers].name = "split"; + driver[ndrivers].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); + ndrivers++; + + driver[ndrivers].name = "multi"; + driver[ndrivers].fapl = fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_multi(fapl, NULL, NULL, NULL, NULL, TRUE); + ndrivers++; /* * Each remaining argument is an hdf5 file followed by an optional slash @@ -2035,19 +2077,20 @@ main (int argc, char *argv[]) file = -1; while (fname && *fname) { - /* Choose a file driver*/ - plist = H5Pcreate(H5P_FILE_ACCESS); - if (strchr(fname, '%')) { - H5Pset_fapl_family(plist, 0, H5P_DEFAULT); + for (dno=0; dno<ndrivers; dno++) { + H5E_BEGIN_TRY { + file = H5Fopen(fname, H5F_ACC_RDONLY, driver[dno].fapl); + } H5E_END_TRY; + if (file>=0) break; } - - /* Try to open the file */ - H5E_BEGIN_TRY { - file = H5Fopen(fname, H5F_ACC_RDONLY, plist); - } H5E_END_TRY; - H5Pclose(plist); - if (file>=0) break; /*success*/ - + if (file>=0) { + if (verbose_g) { + printf("Opened \"%s\" with %s driver.\n", + fname, driver[dno].name); + } + break; /*success*/ + } + /* Shorten the file name; lengthen the object name */ x = oname; oname = strrchr(fname, '/'); |