summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5F.c26
-rw-r--r--src/H5Fdeprec.c41
-rw-r--r--src/H5Fprivate.h1
-rw-r--r--src/H5Fpublic.h2
-rw-r--r--src/H5VLint.c10
-rw-r--r--src/H5VLnative.c17
-rw-r--r--src/H5VLpublic.h9
7 files changed, 81 insertions, 25 deletions
diff --git a/src/H5F.c b/src/H5F.c
index add0480..167ffe3 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -838,7 +838,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Fis_hdf5
+ * Function: H5F_is_hdf5
*
* Purpose: Check the file signature to detect an HDF5 file.
*
@@ -858,17 +858,12 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5Fis_hdf5(const char *name)
+H5F_is_hdf5(const char *name)
{
H5FD_t *file = NULL; /* Low-level file struct */
htri_t ret_value; /* Return value */
- FUNC_ENTER_API(FAIL)
- H5TRACE1("t", "*s", name);
-
- /* Check args and all the boring stuff. */
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
+ FUNC_ENTER_NOAPI_NOINIT
/* Open the file at the virtual file layer */
if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF)))
@@ -883,12 +878,12 @@ done:
if(H5FD_close(file) < 0 && ret_value >= 0)
HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
- FUNC_LEAVE_API(ret_value)
-} /* end H5Fis_hdf5() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_is_hdf5() */
/*-------------------------------------------------------------------------
- * Function: H5Fis_accessable
+ * Function: H5Fis_accessible
*
* Purpose: Check if the file can be opened with the given fapl.
*
@@ -901,7 +896,7 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5Fis_accessable(const char *name, hid_t fapl_id)
+H5Fis_accessible(const char *name, hid_t fapl_id)
{
htri_t ret_value = TRUE; /* Return value */
@@ -912,15 +907,12 @@ H5Fis_accessable(const char *name, hid_t fapl_id)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
-#if 0
- if(H5VL_file_optional(H5VL_FILE_IS_HDF5, &ret_value, name) < 0)
+ if(H5VL_file_misc(fapl_id, H5VL_FILE_IS_ACCESSIBLE, &ret_value, name) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle")
-#endif
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Fis_accessable() */
-
+} /* end H5Fis_accessible() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c
index e3945ff..ef28e13 100644
--- a/src/H5Fdeprec.c
+++ b/src/H5Fdeprec.c
@@ -169,5 +169,46 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fget_info1() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fis_hdf5
+ *
+ * Purpose: Check the file signature to detect an HDF5 file.
+ *
+ * Bugs: This function is not robust: it only uses the default file
+ * driver when attempting to open the file when in fact it
+ * should use all known file drivers.
+ *
+ * Return: Success: TRUE/FALSE
+ *
+ * Failure: Negative
+ *
+ * Programmer: Unknown
+ *
+ * Modifications:
+ * Robb Matzke, 1999-08-02
+ * Rewritten to use the virtual file layer.
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5Fis_hdf5(const char *name)
+{
+ htri_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("t", "*s", name);
+
+ /* Check args and all the boring stuff. */
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
+
+ /* Call private routine */
+ if((ret_value = H5F_is_hdf5(name)) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Fis_hdf5() */
+
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index f65a791..e163f85 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -516,6 +516,7 @@ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id,
H5_DLL herr_t H5F_close(H5F_t *f);
H5_DLL herr_t H5F_try_close(H5F_t *f);
H5_DLL hid_t H5F_reopen(H5F_t *f);
+H5_DLL htri_t H5F_is_hdf5(const char *name);
/* Functions than retrieve values from the file struct */
H5_DLL unsigned H5F_get_intent(const H5F_t *f);
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 6611455..6f7ae37 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -175,7 +175,7 @@ extern "C" {
/* Functions in H5F.c */
H5_DLL htri_t H5Fis_hdf5(const char *filename);
-H5_DLL htri_t H5Fis_accessable(const char *filename, hid_t fapl_id);
+H5_DLL htri_t H5Fis_accessible(const char *container_name, hid_t fapl_id);
H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist);
H5_DLL hid_t H5Fopen(const char *filename, unsigned flags,
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 57df1ce..879de95 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -1187,7 +1187,15 @@ H5VL_file_misc(hid_t id, H5VL_file_misc_t misc_type, hid_t req, ...)
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
+ if (misc_type == H5VL_FILE_IS_ACCESSIBLE) {
+ H5P_genplist_t *plist; /* Property list pointer */
+ /* get the VOL info from the fapl */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+ if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_plugin) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin")
+ }
+ else if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
if(NULL == vol_plugin->file_cls.misc)
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 7a97c1b..49dd760 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -1705,7 +1705,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_file_misc(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_file_misc(hid_t id, H5VL_file_misc_t misc_type, hid_t UNUSED req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1722,7 +1722,7 @@ H5VL_native_file_misc(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t UNUSED req
H5F_t *child = NULL;
/* Check arguments */
- if(H5G_loc(loc_id, &loc) < 0)
+ if(H5G_loc(id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
@@ -1740,7 +1740,7 @@ H5VL_native_file_misc(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t UNUSED req
H5G_loc_t loc;
/* Check arguments */
- if(H5G_loc(loc_id, &loc) < 0)
+ if(H5G_loc(id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
/* Unmount */
@@ -1749,6 +1749,17 @@ H5VL_native_file_misc(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t UNUSED req
break;
}
+ /* H5Fis_accessible */
+ case H5VL_FILE_IS_ACCESSIBLE:
+ {
+ htri_t *ret = va_arg (arguments, htri_t *);
+ const char *name = va_arg (arguments, const char *);
+
+ /* Call private routine */
+ if((*ret = H5F_is_hdf5(name)) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+ break;
+ }
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type")
}
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index 1a68f97..e0b25b4 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -83,7 +83,8 @@ typedef enum H5VL_file_get_t {
/* types for all file misc operations */
typedef enum H5VL_file_misc_t {
H5VL_FILE_MOUNT = 0,
- H5VL_FILE_UNMOUNT = 1
+ H5VL_FILE_UNMOUNT = 1,
+ H5VL_FILE_IS_ACCESSIBLE = 2
} H5VL_file_misc_t;
/* types for all file optional operations */
@@ -205,7 +206,8 @@ typedef struct H5VL_t H5VL_t;
/* H5A routines */
typedef struct H5VL_attr_class_t {
- hid_t (*create)(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req);
+ hid_t (*create)(hid_t loc_id, const char *attr_name, hid_t acpl_id,
+ hid_t aapl_id, hid_t req);
hid_t (*open) (hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t req);
herr_t (*read) (hid_t attr_id, hid_t mem_type_id, void *buf, hid_t req);
herr_t (*write) (hid_t attr_id, hid_t mem_type_id, const void *buf, hid_t req);
@@ -237,7 +239,8 @@ typedef struct H5VL_dataset_class_t {
/* H5F routines */
typedef struct H5VL_file_class_t {
- hid_t (*create)(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req);
+ hid_t (*create)(const char *name, unsigned flags, hid_t fcpl_id,
+ hid_t fapl_id, hid_t req);
hid_t (*open) (const char *name, unsigned flags, hid_t fapl_id, hid_t req);
herr_t (*flush) (hid_t file_id, H5F_scope_t scope, hid_t req);
herr_t (*get) (hid_t file_id, H5VL_file_get_t get_type, hid_t req, va_list arguments);