diff options
author | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 2000-06-06 18:07:20 (GMT) |
---|---|---|
committer | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 2000-06-06 18:07:20 (GMT) |
commit | 4d16bcfecbf51574e3f8bb8cd0e50373892fa462 (patch) | |
tree | 44e97bf287bc7fae2540e6c10211da44ee9517d8 /tools/h5tools.c | |
parent | 6ef640cb9934e6e6fd7b89e902ed974797b91b79 (diff) | |
download | hdf5-4d16bcfecbf51574e3f8bb8cd0e50373892fa462.zip hdf5-4d16bcfecbf51574e3f8bb8cd0e50373892fa462.tar.gz hdf5-4d16bcfecbf51574e3f8bb8cd0e50373892fa462.tar.bz2 |
[svn-r2341] took the code out of h5ls to open files using different drivers and created a function in the tools
library for it(H5ToolsFopen-takes a filename and a char ptr if you want the name of the driver)
added the function to h5tools.c, a header to h5tools.h and changed h5ls.c and h5dump.c to use the new
functions
Diffstat (limited to 'tools/h5tools.c')
-rw-r--r-- | tools/h5tools.c | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/tools/h5tools.c b/tools/h5tools.c index 0fd8925..9011a6e 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 @@ -2230,10 +2230,58 @@ get_objectname(table_t* table, int idx) return(strdup(table->objs[idx].objname)); } +/*------------------------------------------------------------------------- + * 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*/ + 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); +} |