changeset 2148:0b9fd3a88a88

Avoid direct usage of H5Fis_hdf5(), replace with hdf_access() function
author bert <bert>
date Fri, 20 May 2005 16:49:51 +0000
parents 469a8e73ee0d
children 2b88aef65b53
files libsrc/hdf_convenience.c libsrc/hdf_convenience.h libsrc/netcdf_convenience.c
diffstat 3 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libsrc/hdf_convenience.c
+++ b/libsrc/hdf_convenience.c
@@ -2300,6 +2300,22 @@
     return (MI_NOERROR);
 }
 
+/* 
+ * Returns one (1) if the argument is the path name of an existing HDF5
+ * file, or zero if the file does not exist or is not in the right format.
+ */
+int
+hdf_access(const char *path)
+{
+    htri_t status;
+
+    H5E_BEGIN_TRY {
+        status = H5Fis_hdf5(path);
+    } H5E_END_TRY;
+
+    return (status > 0);        /* Return non-zero if success */
+}
+
 #ifdef HDF_TEST
 main(int argc, char **argv)
 {
--- a/libsrc/hdf_convenience.h
+++ b/libsrc/hdf_convenience.h
@@ -48,3 +48,5 @@
 extern int hdf_open(const char *path, int mode);
 extern int hdf_create(const char *path, int mode, struct mi2opts *opts_ptr);
 extern int hdf_close(int fd);
+extern int hdf_access(const char *path);
+
--- a/libsrc/netcdf_convenience.c
+++ b/libsrc/netcdf_convenience.c
@@ -39,7 +39,10 @@
 @CREATED    : July 27, 1992. (Peter Neelin, Montreal Neurological Institute)
 @MODIFIED   : 
  * $Log: netcdf_convenience.c,v $
- * Revision 6.17  2005-05-20 15:39:45  bert
+ * Revision 6.18  2005-05-20 16:49:51  bert
+ * Avoid direct usage of H5Fis_hdf5(), replace with hdf_access() function
+ *
+ * Revision 6.17  2005/05/20 15:39:45  bert
  * Remove and/or conditionalize test code for memory-mapped files (see HDF5_MMAP_TEST)
  *
  * Revision 6.16  2004/12/14 23:53:46  bert
@@ -166,7 +169,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[] = "$Header: /private-cvsroot/minc/libsrc/netcdf_convenience.c,v 6.17 2005-05-20 15:39:45 bert Exp $ MINC (MNI)";
+static char rcsid[] = "$Header: /private-cvsroot/minc/libsrc/netcdf_convenience.c,v 6.18 2005-05-20 16:49:51 bert Exp $ MINC (MNI)";
 #endif
 
 #include "minc_private.h"
@@ -302,7 +305,7 @@
          }
 
 #ifdef MINC2
-	 successful_ncopen = (H5Fis_hdf5(outfile) > 0);
+	 successful_ncopen = hdf_access(outfile);
 	 if (successful_ncopen) {
              break;
          }
@@ -416,8 +419,7 @@
    *created_tempfile = FALSE;
 
 #ifdef MINC2
-   status = H5Fis_hdf5(path);
-   if (status > 0) {
+   if (hdf_access(path)) {
       newfile = strdup(path);
       MI_RETURN(newfile);
    }