summaryrefslogtreecommitdiffstats
path: root/src/H5Ocopy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Ocopy.c')
-rw-r--r--src/H5Ocopy.c120
1 files changed, 80 insertions, 40 deletions
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index dc79e47..85346eb 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -45,7 +45,7 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
-
+#include "H5VLprivate.h" /* VOL */
/****************/
/* Local Macros */
@@ -205,10 +205,78 @@ herr_t
H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id)
{
- H5G_loc_t loc; /* Source group group location */
- H5G_loc_t src_loc; /* Source object group location */
- H5G_loc_t dst_loc; /* Destination group location */
+ void *obj1 = NULL; /* object token of src_id */
+ H5VL_t *vol_plugin1; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ void *obj2 = NULL; /* object token of dst_id */
+ H5VL_t *vol_plugin2; /* VOL plugin information */
+ H5VL_loc_params_t loc_params2;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name,
+ ocpypl_id, lcpl_id);
+
+ /* Get correct property lists */
+ if(H5P_DEFAULT == lcpl_id) {
+ if((lcpl_id = H5L_get_default_lcpl()) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to get default lcpl")
+ } /* end if */
+ else
+ if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
+ /* Get object copy property list */
+ if(H5P_DEFAULT == ocpypl_id)
+ ocpypl_id = H5P_OBJECT_COPY_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list")
+
+ /* get the object */
+ if(NULL == (obj1 = (void *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src ID does not contain VOL information")
+ loc_params1.type = H5VL_OBJECT_BY_SELF;
+ loc_params1.obj_type = H5I_get_type(src_loc_id);
+
+ /* get the object */
+ if(NULL == (obj2 = (void *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst ID does not contain VOL information")
+ loc_params2.type = H5VL_OBJECT_BY_SELF;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
+
+ /* Open the object through the VOL */
+ if((ret_value = H5VL_object_copy(obj1, loc_params1, vol_plugin1, src_name,
+ obj2, loc_params2, vol_plugin2, dst_name,
+ ocpypl_id, lcpl_id, H5AC_dxpl_id, H5_EVENT_QUEUE_NULL)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Ocopy() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_copy
+ *
+ * Purpose: private version of H5Ocopy
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * April, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t H5O_copy(H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id)
+{
+ H5G_loc_t src_loc; /* Source object group location */
/* for opening the destination object */
H5G_name_t src_path; /* Opened source object hier. path */
H5O_loc_t src_oloc; /* Opened source object object location */
@@ -217,19 +285,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(FAIL)
- H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name,
- ocpypl_id, lcpl_id);
-
- /* Check arguments */
- if(H5G_loc(src_loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(H5G_loc(dst_loc_id, &dst_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!src_name || !*src_name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified")
- if(!dst_name || !*dst_name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified")
+ FUNC_ENTER_NOAPI_NOINIT
/* check if destination name already exists */
{
@@ -243,7 +299,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
H5G_loc_reset(&tmp_loc);
/* Check if object already exists in destination */
- if(H5G_loc_find(&dst_loc, dst_name, &tmp_loc, H5P_DEFAULT, H5AC_dxpl_id) >= 0) {
+ if(H5G_loc_find(dst_loc, dst_name, &tmp_loc, H5P_DEFAULT, H5AC_dxpl_id) >= 0) {
H5G_name_free(&tmp_path);
HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "destination object already exists")
} /* end if */
@@ -255,7 +311,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
H5G_loc_reset(&src_loc);
/* Find the source object to copy */
- if(H5G_loc_find(&loc, src_name, &src_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0)
+ if(H5G_loc_find(loc, src_name, &src_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found")
loc_found = TRUE;
@@ -264,24 +320,8 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
obj_open = TRUE;
- /* Get correct property lists */
- if(H5P_DEFAULT == lcpl_id) {
- if((lcpl_id = H5L_get_default_lcpl()) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to get default lcpl")
- } /* end if */
- else
- if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
-
- /* Get object copy property list */
- if(H5P_DEFAULT == ocpypl_id)
- ocpypl_id = H5P_OBJECT_COPY_DEFAULT;
- else
- if(TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list")
-
/* Do the actual copying of the object */
- if(H5O_copy_obj(&src_loc, &dst_loc, dst_name, ocpypl_id, lcpl_id) < 0)
+ if(H5O_copy_obj(&src_loc, dst_loc, dst_name, ocpypl_id, lcpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
done:
@@ -290,8 +330,8 @@ done:
if(obj_open)
H5O_close(&src_oloc);
- FUNC_LEAVE_API(ret_value)
-} /* end H5Ocopy() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_copy() */
/*-------------------------------------------------------------------------
@@ -1769,7 +1809,7 @@ H5O_copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src,
HDassert(oh_src);
HDassert(oloc_dst);
HDassert(oloc_dst->file);
- HDassert(H5F_FILE_ID(oloc_dst->file) >= 0);
+ HDassert(H5F_FILE_ID(oloc_dst->file));
HDassert(cpy_info);
/* Allocate key */
@@ -1881,7 +1921,7 @@ H5O_copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src,
/* Traverse the destination file, adding committed datatypes to the skip
* list */
- if(H5G_visit(H5F_FILE_ID(oloc_dst->file), "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O_copy_search_comm_dt_cb, &udata, H5P_LINK_ACCESS_DEFAULT, dxpl_id) < 0)
+ if(H5G_visit(&dst_root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O_copy_search_comm_dt_cb, &udata, H5P_LINK_ACCESS_DEFAULT, dxpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
cpy_info->dst_dt_list_complete = TRUE;
} /* end if */