summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2019-06-13 21:58:58 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2019-06-13 21:58:58 (GMT)
commit650f9e616dbb60aa8ef1706a6968aacd1c23a568 (patch)
tree3706988dbb96e076b82246036e6d7117e4221702 /src
parent054059a30c081a88e0a2dfe05d036d617f434e55 (diff)
parentbb5e7822f447b8a175e807e2e7bad5e0192394e5 (diff)
downloadhdf5-650f9e616dbb60aa8ef1706a6968aacd1c23a568.zip
hdf5-650f9e616dbb60aa8ef1706a6968aacd1c23a568.tar.gz
hdf5-650f9e616dbb60aa8ef1706a6968aacd1c23a568.tar.bz2
Merge pull request #1727 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:H5Fdelete_vol_only to develop
* commit 'bb5e7822f447b8a175e807e2e7bad5e0192394e5': Fixed an error string typo Added H5Fdelete call and VOL support (but no VFD/native implementation).
Diffstat (limited to 'src')
-rw-r--r--src/H5F.c73
-rw-r--r--src/H5Fint.c4
-rw-r--r--src/H5Fpublic.h1
-rw-r--r--src/H5VLcallback.c2
-rw-r--r--src/H5VLnative_file.c8
-rw-r--r--src/H5VLpassthru.c2
-rw-r--r--src/H5VLpublic.h3
-rw-r--r--src/H5err.txt1
-rw-r--r--src/H5trace.c3
9 files changed, 86 insertions, 11 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 779c940..d216cd2 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -560,20 +560,21 @@ done:
*
* Purpose: Check if the file can be opened with the given fapl.
*
- * Return: TRUE/FALSE/FAIL
+ * Return: Succeed: TRUE/FALSE
+ * Failure: FAIL (includes file does not exist)
*
*-------------------------------------------------------------------------
*/
htri_t
-H5Fis_accessible(const char *name, hid_t fapl_id)
+H5Fis_accessible(const char *filename, hid_t fapl_id)
{
htri_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE2("t", "*si", name, fapl_id);
+ H5TRACE2("t", "*si", filename, fapl_id);
/* Check args */
- if(!name || !*name)
+ if(!filename || !*filename)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
/* Check the file access property list */
@@ -584,7 +585,7 @@ H5Fis_accessible(const char *name, hid_t fapl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list")
/* Check if file is accessible */
- if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, name, &ret_value) < 0)
+ if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &ret_value) < 0)
HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5")
done:
@@ -838,6 +839,68 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Fdelete
+ *
+ * Purpose: Deletes an HDF5 file.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fdelete(const char *filename, hid_t fapl_id)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
+ htri_t is_hdf5 = FAIL;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "*si", filename, fapl_id);
+
+ /* Check args */
+ if(!filename || !*filename)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
+
+ /* Check the file access property list */
+ if(H5P_DEFAULT == fapl_id)
+ fapl_id = H5P_FILE_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+
+ /* Verify access property list and set up collective metadata if appropriate */
+ if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
+
+ /* Get the VOL info from the fapl */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list")
+ if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info")
+
+ /* Stash a copy of the "top-level" connector property, before any pass-through
+ * connectors modify or unwrap it.
+ */
+ if(H5CX_set_vol_connector_prop(&connector_prop) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context")
+
+ /* Make sure this is HDF5 storage for this VOL connector */
+ if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &is_hdf5) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5")
+ if(!is_hdf5)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "not an HDF5 file")
+
+ /* Delete the file */
+ if(H5VL_file_specific(NULL, H5VL_FILE_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &ret_value) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDELETEFILE, FAIL, "unable to delete the file")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Fdelete() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Freopen
*
* Purpose: Reopen a file. The new file handle which is returned points
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 2e8771c..ee9afed 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -863,7 +863,7 @@ H5F__is_hdf5(const char *name, hid_t fapl_id)
* should work with arbitrary VFDs, unlike H5Fis_hdf5().
*/
if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to open file")
/* The file is an hdf5 file if the hdf5 file signature can be found */
if(H5FD_locate_signature(file, &sig_addr) < 0)
@@ -874,7 +874,7 @@ done:
/* Close the file */
if(file)
if(H5FD_close(file) < 0 && TRUE == ret_value)
- HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F__is_hdf5() */
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 52f1ee2..dd794e4 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -233,6 +233,7 @@ H5_DLL hid_t H5Fopen(const char *filename, unsigned flags,
H5_DLL hid_t H5Freopen(hid_t file_id);
H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope);
H5_DLL herr_t H5Fclose(hid_t file_id);
+H5_DLL herr_t H5Fdelete(const char *filename, hid_t fapl_id);
H5_DLL hid_t H5Fget_create_plist(hid_t file_id);
H5_DLL hid_t H5Fget_access_plist(hid_t file_id);
H5_DLL herr_t H5Fget_intent(hid_t file_id, unsigned *intent);
diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c
index 2d1274c..696ccab 100644
--- a/src/H5VLcallback.c
+++ b/src/H5VLcallback.c
@@ -3041,7 +3041,7 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t
arg_started = TRUE;
/* Special treatment of file access check */
- if(specific_type == H5VL_FILE_IS_ACCESSIBLE) {
+ if(specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) {
H5P_genplist_t *plist; /* Property list pointer */
H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
va_list tmp_args; /* argument list passed from the API call */
diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c
index 8903911..eeaade6 100644
--- a/src/H5VLnative_file.c
+++ b/src/H5VLnative_file.c
@@ -386,10 +386,16 @@ H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type,
/* Call private routine */
if((*ret = H5F__is_hdf5(name, fapl_id)) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "error in HDF5 file check")
break;
}
+ /* H5Fdelete */
+ case H5VL_FILE_DELETE:
+ {
+ HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "H5Fdelete() is currently not supported in the native VOL connector")
+ break;
+ }
default:
diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c
index ef92ddb..78150c5 100644
--- a/src/H5VLpassthru.c
+++ b/src/H5VLpassthru.c
@@ -1733,7 +1733,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type,
/* Re-issue 'file specific' call, using the unwrapped pieces */
ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, (int)loc_type, name, child_file->under_object, plist_id);
} /* end if */
- else if(specific_type == H5VL_FILE_IS_ACCESSIBLE) {
+ else if(specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) {
H5VL_pass_through_info_t *info;
hid_t fapl_id, under_fapl_id;
const char *name;
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index a765d2a..85437f9 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -105,7 +105,8 @@ typedef enum H5VL_file_specific_t {
H5VL_FILE_REOPEN, /* Reopen the file */
H5VL_FILE_MOUNT, /* Mount a file */
H5VL_FILE_UNMOUNT, /* Unmount a file */
- H5VL_FILE_IS_ACCESSIBLE /* Check if a file is accessible */
+ H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */
+ H5VL_FILE_DELETE /* Delete a file */
} H5VL_file_specific_t;
/* types for group GET callback */
diff --git a/src/H5err.txt b/src/H5err.txt
index 4eedc0f..d4edfba 100644
--- a/src/H5err.txt
+++ b/src/H5err.txt
@@ -134,6 +134,7 @@ MINOR, FILEACC, H5E_NOTHDF5, Not an HDF5 file
MINOR, FILEACC, H5E_BADFILE, Bad file ID accessed
MINOR, FILEACC, H5E_TRUNCATED, File has been truncated
MINOR, FILEACC, H5E_MOUNT, File mount error
+MINOR, FILEACC, H5E_CANTDELETEFILE, Unable to delete file
# Generic low-level file I/O errors
MINOR, FILE, H5E_SEEKERROR, Seek failed
diff --git a/src/H5trace.c b/src/H5trace.c
index 1125072..ff81ae8 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -2758,6 +2758,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case H5VL_FILE_IS_ACCESSIBLE:
HDfprintf(out, "H5VL_FILE_IS_ACCESSIBLE");
break;
+ case H5VL_FILE_DELETE:
+ HDfprintf(out, "H5VL_FILE_DELETE");
+ break;
default:
HDfprintf(out, "%ld", (long)specific);
break;