diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2018-10-29 22:24:33 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2018-10-29 22:24:33 (GMT) |
commit | 8c37f531a9fd1f0f9e4a432e53ee40a0249e906e (patch) | |
tree | 35de43030359197bf2108c7aa193bed378b4c7cf | |
parent | aaaf1acc08846684af8750db68cdf6d02bbc540f (diff) | |
download | hdf5-8c37f531a9fd1f0f9e4a432e53ee40a0249e906e.zip hdf5-8c37f531a9fd1f0f9e4a432e53ee40a0249e906e.tar.gz hdf5-8c37f531a9fd1f0f9e4a432e53ee40a0249e906e.tar.bz2 |
Switch to using VOL callbacks, instead of direct calls to internal routines.
-rw-r--r-- | src/H5Fdeprec.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index 6fee596..36eae40 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -96,7 +96,8 @@ herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) { - H5F_t *f; /* Top file in mount hierarchy */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; H5F_info2_t finfo2; /* Current file info struct */ herr_t ret_value = SUCCEED; /* Return value */ @@ -107,27 +108,17 @@ H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) if(!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* For file IDs, get the file object directly - * - * (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5VL_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - } - else { - H5G_loc_t loc; /* Object location */ - - /* Get symbol table entry */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") - f = loc.oloc->file; - } - HDassert(f->shared); - - /* Get the current file info */ - if(H5F__get_info(f, &finfo2) < 0) + /* Check the type */ + type = H5I_get_type(obj_id); + if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && H5I_ATTR != type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Get the file object */ + if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Get the file information */ + if(H5VL_file_optional(vol_obj->data, vol_obj->plugin->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_INFO, type, &finfo2) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") /* Copy the compatible fields into the older struct */ @@ -165,12 +156,11 @@ H5Fis_hdf5(const char *name) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "no file name specified") - /* call the private is_HDF5 function */ - if((ret_value = H5F__is_hdf5(name, H5P_FILE_ACCESS_DEFAULT)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable open file") + /* Check if file is accessible */ + if(H5VL_file_specific(NULL, NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5P_FILE_ACCESS_DEFAULT, name, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable to determine if file is accessible as HDF5") done: - FUNC_LEAVE_API(ret_value) } /* end H5Fis_hdf5() */ @@ -209,16 +199,13 @@ done: * *------------------------------------------------------------------------- */ -/* XXX (VOL MERGE): This could go in the native VOL driver under 'optional'. - */ herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format) { H5VL_object_t *vol_obj; /* File as VOL object */ - H5F_t *f; /* File */ - H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ - H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ + H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, latest_format); @@ -226,11 +213,14 @@ H5Fset_latest_format(hid_t file_id, hbool_t latest_format) /* Check args */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") - f = (H5F_t *)(vol_obj->data); + + /* Set up collective metadata if appropriate */ + if(H5CX_set_loc(file_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* 'low' and 'high' are both initialized to LATEST. * If latest format is not expected, set 'low' to EARLIEST - */ + */ if(!latest_format) low = H5F_LIBVER_EARLIEST; @@ -238,6 +228,10 @@ H5Fset_latest_format(hid_t file_id, hbool_t latest_format) if(H5F__set_libver_bounds(f, low, high) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + /* Set the library's version bounds */ + if(H5VL_file_optional(vol_obj->data, vol_obj->plugin->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_SET_LIBVER_BOUNDS, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") + done: FUNC_LEAVE_API(ret_value) } /* end H5Fset_latest_format() */ |