diff options
author | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 2000-06-07 19:52:19 (GMT) |
---|---|---|
committer | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 2000-06-07 19:52:19 (GMT) |
commit | 798760fe15b05171cdd6b1a76ac4ad60479b422d (patch) | |
tree | a42c133d71a73c61d88058c4df93fc7f7b3989fe /tools | |
parent | 9d25162448896472bc7866a4e63aeca1a611d90c (diff) | |
download | hdf5-798760fe15b05171cdd6b1a76ac4ad60479b422d.zip hdf5-798760fe15b05171cdd6b1a76ac4ad60479b422d.tar.gz hdf5-798760fe15b05171cdd6b1a76ac4ad60479b422d.tar.bz2 |
[svn-r2360] made the same changes I made to the dev branch. decided to add to the release branch after all
since the changes will not affect the release branch. the changes have a conditional compile statement
around some of it so it shouldnt break anything
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5dump.c | 8 | ||||
-rw-r--r-- | tools/h5ls.c | 50 | ||||
-rw-r--r-- | tools/h5tools.c | 63 | ||||
-rw-r--r-- | tools/h5tools.h | 4 |
4 files changed, 79 insertions, 46 deletions
diff --git a/tools/h5dump.c b/tools/h5dump.c index 927d088..27668b2 100644 --- a/tools/h5dump.c +++ b/tools/h5dump.c @@ -1307,8 +1307,8 @@ int main(int argc, char *argv[]) { hid_t fid, gid, dsetid, typeid; - hid_t plist=H5P_DEFAULT; - const char *fname = NULL; + + char *fname = NULL; int i, index, curr_arg, display_bb=0, display_all=1, newwidth= 0; int nopts=0, *opts; char *buf, name[128], name1[128]; @@ -1430,7 +1430,9 @@ main(int argc, char *argv[]) if (argv[argc-1][0] == '\\') fname = &argv[argc-1][1]; else fname = argv[argc-1]; - if ((fid = H5Fopen (fname, H5F_ACC_RDONLY, plist)) < 0) { + fid = H5ToolsFopen(fname, NULL); + + if (fid < 0){ fprintf (stderr, "h5dump error: unable to open file %s \n", fname); free(opts); exit(1); diff --git a/tools/h5ls.c b/tools/h5ls.c index 1cad442..ce2141e 100644 --- a/tools/h5ls.c +++ b/tools/h5ls.c @@ -26,7 +26,7 @@ #include <H5Fpublic.h> #endif -#define NDRIVERS 10 + /* * If defined then include the file name as part of the object name when * printing full object names. Otherwise leave the file name off. @@ -1905,22 +1905,17 @@ get_width(void) int main (int argc, char *argv[]) { - hid_t file=-1, root=-1, fapl=-1; + hid_t file=-1, root=-1; char *fname=NULL, *oname=NULL, *x; const char *progname; const char *s = NULL; char *rest, *container=NULL; - int argno, dno; + int argno; H5G_stat_t sb; iter_t iter; static char root_name[] = "/"; - - int ndrivers=0; - - struct { - const char *name; - hid_t fapl; - } driver[NDRIVERS]; + char drivername[50]; + memset(drivername, '\0',50); /* Build display table */ @@ -2078,31 +2073,6 @@ main (int argc, char *argv[]) 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++; -#if defined VERSION13 - 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++; -#endif - /* * Each remaining argument is an hdf5 file followed by an optional slash * and object name. * @@ -2122,16 +2092,12 @@ main (int argc, char *argv[]) file = -1; while (fname && *fname) { - 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; - } + + file = H5ToolsFopen(fname,drivername); if (file>=0) { if (verbose_g) { printf("Opened \"%s\" with %s driver.\n", - fname, driver[dno].name); + fname, drivername); } break; /*success*/ } diff --git a/tools/h5tools.c b/tools/h5tools.c index 0af02ac..e840756 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -105,7 +105,7 @@ extern int get_table_idx(table_t *table, unsigned long *); extern int get_tableflag(table_t*, int); extern int set_tableflag(table_t*, int); extern char* get_objectname(table_t*, int); - +extern hid_t H5ToolsFopen(char* fname, char* drivername); /*------------------------------------------------------------------------- * Function: h5dump_str_close @@ -2233,6 +2233,67 @@ get_objectname(table_t* table, int idx) } +/*------------------------------------------------------------------------- + * Function: opens a file using the list of drivers + * + * Purpose: + * + * Return: Success: a file id for the opened file + * + * Failure: -1; + * + *-----------------------------------------------------------------------*/ + +hid_t H5ToolsFopen(char* fname, char* drivername){ + + typedef struct driver_t { + const char *name; + hid_t fapl; + } driver_t; + + hid_t fid, fapl = H5P_DEFAULT; + int ndrivers = 0, drivernum; + driver_t driver[NDRIVERS]; + + /*taken from h5ls*/ + /* + * 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++; +#if defined VERSION13 + 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++; +#endif + for (drivernum = 0; drivernum<ndrivers;drivernum++){ + H5E_BEGIN_TRY { + fid = H5Fopen(fname, H5F_ACC_RDONLY, driver[drivernum].fapl); + } H5E_END_TRY; + if (fid >= 0) break; + } + if (drivername){ + memcpy(drivername,driver[drivernum].name,strlen(driver[drivernum].name)); + } + return (fid); +} + + + diff --git a/tools/h5tools.h b/tools/h5tools.h index 22ab2d3..6fe3a24 100644 --- a/tools/h5tools.h +++ b/tools/h5tools.h @@ -434,3 +434,7 @@ extern int nCols; /* Definitions of useful routines */ void print_version(const char *program_name); +/*used to open files so we can use different drivers*/ +hid_t H5ToolsFopen(char* fname, char* drivername); + +#define NDRIVERS 10 |