summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Ocopy.c91
-rw-r--r--src/H5Oprivate.h3
-rw-r--r--src/H5VL.c48
-rw-r--r--src/H5VLdummy.c17
-rw-r--r--src/H5VLnative.c42
-rw-r--r--src/H5VLprivate.h4
-rw-r--r--src/H5VLpublic.h2
7 files changed, 153 insertions, 54 deletions
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index 7b812ec..c1622d8 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,53 @@ 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 */
+ 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")
+
+ /* Open the object through the VOL */
+ if((ret_value = H5VL_object_copy(src_loc_id, src_name, dst_loc_id, dst_name,
+ ocpypl_id, lcpl_id)) < 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 +260,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 +274,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 +286,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 +295,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 +305,8 @@ done:
if(obj_open)
H5O_close(&src_oloc);
- FUNC_LEAVE_API(ret_value)
-} /* end H5Ocopy() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_copy() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 8e2dfa4..0acffae 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -738,6 +738,9 @@ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst
H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id,
H5F_t *file_dst, void *_dst_ref, size_t ref_count, H5R_type_t ref_type,
H5O_copy_t *cpy_info);
+H5_DLL herr_t H5O_copy(H5G_loc_t *src_loc, const char *src_name,
+ H5G_loc_t *dst_loc, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id);
/* Debugging routines */
H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth);
diff --git a/src/H5VL.c b/src/H5VL.c
index 23a2d6b..353f36f 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -2049,7 +2049,6 @@ H5VL_link_get(hid_t uid, H5VL_link_get_t get_type, ...)
{
H5VL_id_wrapper_t *id_wrapper; /* user id structure */
va_list arguments; /* argument list passed from the API call */
- H5I_type_t id_type; /* Type of ID */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
@@ -2126,8 +2125,8 @@ done:
hid_t
H5VL_object_open_by_loc(hid_t uid, void *obj_loc, hid_t lapl_id)
{
- H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the object will be opend */
- H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend object*/
+ H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the object will be opend */
+ H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend object*/
H5I_type_t id_type;
hid_t object_id; /* actual object ID */
hid_t ret_value; /* Return value */
@@ -2178,6 +2177,49 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_object_copy
+ *
+ * Purpose: Copies an object to another destination through the VOL
+ *
+ * Return: Success: Non Negative
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * April, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5VL_object_copy(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 )
+{
+ H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the object will be opend */
+ H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend object*/
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* unwrap the IDs and return an error if they belong to different VOL plugins */
+ if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier")
+ if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier")
+
+ if (id_wrapper1->vol_plugin != id_wrapper2->vol_plugin)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be copied")
+
+ if(NULL == id_wrapper1->vol_plugin->object_cls.copy)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object copy' method")
+ if((ret_value = (id_wrapper1->vol_plugin->object_cls.copy)
+ (id_wrapper1->obj_id, src_name, id_wrapper2->obj_id, dst_name, ocpypl_id, lcpl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "copy failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_object_copy() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_object_lookup
*
* Purpose: Lookup the object location in the file
diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c
index 45527d0..5503351 100644
--- a/src/H5VLdummy.c
+++ b/src/H5VLdummy.c
@@ -69,15 +69,16 @@ H5VL_class_t H5VL_dummy_g = {
NULL, /* read */
NULL, /* write */
NULL, /* delete */
+ NULL, /* delete */
NULL /* close */
},
{ /* datatype_cls */
- NULL, /* commit */
- NULL /* open */
+ NULL, /* commit */
+ NULL /* open */
},
{ /* dataset_cls */
- NULL, /* create */
- NULL, /* open */
+ NULL, /* create */
+ NULL, /* open */
NULL,
NULL,
NULL,
@@ -85,11 +86,12 @@ H5VL_class_t H5VL_dummy_g = {
NULL
},
{ /* file_cls */
- H5VL_dummy_file_create, /* create */
- H5VL_dummy_file_open, /* open */
+ H5VL_dummy_file_create, /* create */
+ H5VL_dummy_file_open, /* open */
NULL,
NULL,
- H5VL_dummy_file_close /* close */
+ NULL,
+ H5VL_dummy_file_close /* close */
},
{ /* group_cls */
NULL,
@@ -105,7 +107,6 @@ H5VL_class_t H5VL_dummy_g = {
},
{ /* object_cls */
NULL,
- NULL, /* move */
NULL, /* copy */
NULL,
NULL,
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 8abad51..69cf274 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -104,6 +104,8 @@ static herr_t H5VL_native_link_get(hid_t loc_id, H5VL_link_get_t get_type, va_li
static herr_t H5VL_native_link_delete(hid_t loc_id, const char *name, void *udata, hid_t lapl_id);
static hid_t H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id);
+static herr_t H5VL_native_object_copy(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 );
static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, va_list arguments);
static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, va_list arguments);
static herr_t H5VL_native_object_generic(hid_t id, H5VL_object_generic_t generic_type, va_list arguments);
@@ -157,8 +159,7 @@ H5VL_class_t H5VL_native_g = {
},
{ /* object_cls */
H5VL_native_object_open, /* open */
- NULL, /* move */
- NULL, /* copy */
+ H5VL_native_object_copy, /* copy */
H5VL_native_object_lookup, /* lookup */
H5VL_native_object_get, /* get */
H5VL_native_object_generic, /* generic */
@@ -2337,6 +2338,43 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_native_object_copy
+ *
+ * Purpose: Copys a object inside a native h5 file.
+ *
+ * Return: Success: object id.
+ * Failure: NULL
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_native_object_copy(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 src_loc; /* Source object group location */
+ H5G_loc_t dst_loc; /* Destination group location */
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Check arguments */
+ if(H5G_loc(src_loc_id, &src_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")
+
+ /* Open the object */
+ if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object")
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_native_object_copy() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_native_object_lookup
*
* Purpose: Lookup the object location in the file
diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h
index acb64a3..2aacc2f 100644
--- a/src/H5VLprivate.h
+++ b/src/H5VLprivate.h
@@ -94,10 +94,12 @@ H5_DLL herr_t H5VL_link_get(hid_t loc_id, H5VL_link_get_t get_type, ...);
H5_DLL herr_t H5VL_link_delete(hid_t loc_id, const char *name, void *udata, hid_t lapl_id);
H5_DLL hid_t H5VL_object_open_by_loc(hid_t uid, void *obj_loc, hid_t lapl_id);
-H5_DLL herr_t H5VL_object_close(hid_t uid);
+H5_DLL herr_t H5VL_object_copy(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 );
H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, ...);
H5_DLL herr_t H5VL_object_generic(hid_t id, H5VL_object_generic_t generic_type, ...);
H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, ...);
+H5_DLL herr_t H5VL_object_close(hid_t uid);
H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, H5VL_class_t *vol_cls);
H5_DLL herr_t H5VL_fapl_close(H5VL_class_t *vol_cls);
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index fb61135..e6df32f 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -179,8 +179,6 @@ typedef struct H5VL_link_class_t {
/* H5O routines */
typedef struct H5VL_object_class_t {
hid_t (*open) (hid_t loc_id, void *obj_loc, hid_t lapl_id);
- herr_t (*move) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
- const char *dest_name, hid_t lcpl, hid_t lapl);
herr_t (*copy) (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 );
herr_t (*lookup)(hid_t loc_id, H5VL_object_lookup_t lookup_type, va_list arguments);