summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Dcompact.c13
-rw-r--r--src/H5Dcontig.c9
-rw-r--r--src/H5Distore.c13
-rw-r--r--src/H5G.c192
-rw-r--r--src/H5Gnode.c2
-rw-r--r--src/H5Gpkg.h1
-rw-r--r--src/H5Gprivate.h6
-rw-r--r--src/H5Gpublic.h13
-rw-r--r--src/H5O.c64
-rw-r--r--src/H5Oattr.c8
-rw-r--r--src/H5Ocont.c8
-rw-r--r--src/H5Odtype.c6
-rw-r--r--src/H5Oefl.c8
-rw-r--r--src/H5Olayout.c8
-rw-r--r--src/H5Olink.c16
-rw-r--r--src/H5Opkg.h6
-rw-r--r--src/H5Opline.c6
-rw-r--r--src/H5Oprivate.h8
-rw-r--r--src/H5Oshared.c58
-rw-r--r--src/H5Ostab.c15
-rw-r--r--src/H5P.c47
-rwxr-xr-xsrc/H5Pocpl.c93
-rw-r--r--src/H5Ppublic.h7
-rw-r--r--src/H5T.c6
-rwxr-xr-xtest/objcopy.c1601
25 files changed, 1965 insertions, 249 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 0ad8e05..aaa04ea 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -167,6 +167,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src,
hid_t tid_dst = -1; /* Datatype ID for destination datatype */
hid_t tid_mem = -1; /* Datatype ID for memory datatype */
void *buf = NULL; /* Buffer for copying data */
+ void *bkg = NULL; /* Temporary buffer for copying data */
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
hid_t buf_sid = -1; /* ID for buffer dataspace */
herr_t ret_value = SUCCEED; /* Return value */
@@ -251,11 +252,11 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src,
/* Allocate memory for recclaim buf */
if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Allocate memory for copying the chunk */
if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
HDmemcpy(buf, layout_src->u.compact.buf, layout_src->u.compact.size);
@@ -265,8 +266,12 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src,
HDmemcpy(reclaim_buf, buf, buf_size);
+ /* allocate temporary bkg buff for data conversion */
+ if(NULL == (bkg = H5FL_BLK_CALLOC(type_conv, buf_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
/* Convert from memory to destination file */
- if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0)
+ if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
HDmemcpy(layout_dst->u.compact.buf, buf, layout_dst->u.compact.size);
@@ -292,6 +297,8 @@ done:
H5FL_BLK_FREE(type_conv, buf);
if(reclaim_buf)
H5FL_BLK_FREE(type_conv, reclaim_buf);
+ if(bkg)
+ H5FL_BLK_FREE(type_conv, bkg);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_compact_copy() */
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index f6d1648..97fd043 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -1015,6 +1015,7 @@ H5D_contig_copy(H5F_t *f_src, H5O_layout_t *layout_src,
hsize_t total_src_nbytes; /* Total number of bytes to copy */
size_t buf_size; /* Size of copy buffer */
void *buf = NULL; /* Buffer for copying data */
+ void *bkg = NULL; /* Temporary buffer for copying data */
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
H5S_t *buf_space = NULL; /* Dataspace describing buffer */
hid_t buf_sid = -1; /* ID for buffer dataspace */
@@ -1164,8 +1165,12 @@ H5D_contig_copy(H5F_t *f_src, H5O_layout_t *layout_src,
/* Copy into another buffer, to reclaim memory later */
HDmemcpy(reclaim_buf, buf, mem_nbytes);
+ /* allocate temporary bkg buff for data conversion */
+ if(NULL == (bkg = H5FL_BLK_CALLOC(type_conv, buf_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer")
+
/* Convert from memory to destination file */
- if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0)
+ if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
/* Reclaim space from variable length data */
@@ -1200,6 +1205,8 @@ done:
H5FL_BLK_FREE(type_conv, buf);
if(reclaim_buf)
H5FL_BLK_FREE(type_conv, reclaim_buf);
+ if(bkg)
+ H5FL_BLK_FREE(type_conv, bkg);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_contig_copy() */
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 8ab2527..bcf5fee 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -312,6 +312,9 @@ H5FL_SEQ_DEFINE_STATIC(size_t);
/* Declare a free list to manage the raw page information */
H5FL_BLK_DEFINE_STATIC(chunk_page);
+/* Declare extern the free list to manage blocks of type conversion data */
+H5FL_BLK_EXTERN(type_conv);
+
/*-------------------------------------------------------------------------
* Function: H5D_istore_get_shared
@@ -985,6 +988,7 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key, haddr_t a
H5D_istore_it_ud4_t *udata = (H5D_istore_it_ud4_t *)_udata;
const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key;
H5D_istore_ud1_t udata_dst; /* User data about new destination chunk */
+ void *bkg = NULL; /* Temporary buffer for copying data */
hbool_t is_vlen = FALSE;
/* General information about chunk copy */
@@ -1053,8 +1057,12 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key, haddr_t a
/* Copy into another buffer, to reclaim memory later */
HDmemcpy(reclaim_buf, buf, reclaim_buf_size);
+ /* allocate temporary bkg buff for data conversion */
+ if(NULL == (bkg = H5FL_BLK_CALLOC(type_conv, buf_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed")
+
/* Convert from memory to destination file */
- if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0)
+ if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5B_ITER_ERROR, "datatype conversion failed")
/* Reclaim space from variable length data */
@@ -1087,6 +1095,9 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key, haddr_t a
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, H5B_ITER_ERROR, "unable to write raw data to file")
done:
+ if(bkg)
+ H5FL_BLK_FREE(type_conv, bkg);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_iter_copy() */
diff --git a/src/H5G.c b/src/H5G.c
index 0d7bd85..acdd54f 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -181,8 +181,7 @@ static herr_t H5G_move(H5G_loc_t *src_loc, const char *src_name,
H5G_loc_t *dst_loc, const char *dst_name, hid_t dxpl_id);
static herr_t H5G_insertion_file_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/);
-static herr_t H5G_copy(H5G_loc_t *src_loc, H5G_loc_t *dst_loc,
- const char *name_dst, hid_t plist_id);
+static herr_t H5G_copy(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_t plist_id);
/*-------------------------------------------------------------------------
@@ -285,15 +284,21 @@ done:
* specified NAME, and creation property list GCPL_ID and access
* property list GAPL_ID.
*
- * The optional SIZE_HINT specifies how much file space to
- * reserve to store the names that will appear in this
- * group. If a non-positive value is supplied for the SIZE_HINT
- * then a default size is chosen.
- *
* Given the default setting, H5Gcreate_expand() will have the
* same function of H5Gcreate()
*
- * See also: H5Gcreate(), H5Dcreate_expand()
+ * Usage: H5Gcreate_expand(loc_id, char *name, gcpl_id, gapl_id)
+ * hid_t loc_id; IN: File or group identifier
+ * const char *name; IN: Absolute or relative name of the new group
+ * hid_t gcpl_id; IN: Property list for group creation
+ * hid_t gapl_id; IN: Property list for group access
+ *
+ * Example: To create missing groups "A" and "B01" along the given path "/A/B01/grp"
+ * hid_t create_id = H5Pcreate(H5P_GROUP_CREATE);
+ * int status = H5Pset_create_intermediate_group(create_id, TRUE);
+ * hid_t gid = H5Gcreate_expand(file_id, "/A/B01/grp", create_id, H5P_DEFAULT);
+ *
+ * See also: H5Gcreate(), H5Dcreate_expand(), H5Pset_create_intermediate_group()
*
* Errors:
*
@@ -1055,7 +1060,44 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Gcopy
*
- * Purpose: Copy an object to destination location
+ * Purpose: Copy an object (group or dataset) to destination location
+ * within a file or cross files. PLIST_ID is a property list
+ * which is used to pass user options and properties to the
+ * copy.
+ *
+ * OPTIONS THAT MAY APPLY TO COPY IN THE FUTURE.
+ * H5G_COPY_CREATE_INTERMEDIATE_GROUP_FLAG
+ * Do not create missing groups when create a group (default)
+ * Create missing groups when create a group
+ * H5G_COPY_SHALLOW_HIERARCHY_FLAG
+ * Recursively copy all objects below the group (default)
+ * Only immediate members.
+ * H5G_COPY_EXPAND_SOFT_LINK_FLAG
+ * Keep soft links as they are (default)
+ * Expand them into new objects
+ * H5G_COPY_EXPAND_EXT_LINK_FLAG
+ * Keep external links as they are (default)
+ * Expand them into new objects
+ * H5G_COPY_EXPAND_OBJ_REFERENCE_FLAG
+ * Update only the values of object references (default)
+ * Copy objects that are pointed by references
+ * H5G_COPY_WITHOUT_ATTR_FLAG
+ * Copy object along with all its attributes (default)
+ * Copy object without copying attributes
+ *
+ * PROPERTIES THAT MAY APPLY TO COPY IN FUTURE
+ * Change data layout such as chunk size
+ * Add filter such as data compression.
+ * Add an attribute to the copied object(s) that say the date/time
+ * for the copy or other information about the source file.
+ *
+ * Usage: H5Gcopy(src_loc_id, src_name, dst_loc_id, dst_name, plist_id)
+ * hid_t src_loc_id IN: Source file or group identifier.
+ * const char *src_name IN: Name of the source object to be copied
+ * hid_t dst_loc_id IN: Destination file or group identifier
+ * const char *dst_name IN: Name of the destination object
+ * hid_t plist_id IN: Properties which apply to the copy
+ *
*
* Return: Non-negative on success/Negative on failure
*
@@ -1065,35 +1107,63 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Gcopy(hid_t src_id, hid_t dst_id, const char *name_dst, hid_t plist_id)
+H5Gcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
+ const char *dst_name, hid_t plist_id)
{
- H5G_loc_t src_loc; /* Source object group location */
- H5G_loc_t dst_loc; /* Destination group location */
- herr_t ret_value = SUCCEED; /* Return value */
+ 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 */
+
+ /* 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 */
+ hbool_t ent_found = FALSE; /* Entry at 'name' found */
+ hbool_t obj_open = FALSE; /* Entry at 'name' found */
+
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Gcopy, FAIL)
- H5TRACE4("e","iisi",src_id,dst_id,name_dst,plist_id);
/* Check arguments */
- if(H5G_loc(src_id, &src_loc) < 0)
+ if(H5G_loc(src_loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(H5G_loc(dst_id, &dst_loc) < 0)
+ if(H5G_loc(dst_loc_id, &dst_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name_dst || !*name_dst)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
+ 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")
+
+ /* Set up opened group location to fill in */
+ src_loc.oloc = &src_oloc;
+ src_loc.path = &src_path;
+ H5G_loc_reset(&src_loc);
-/* Get correct property list */
-/* XXX: This is a kludge, to use the datatype creation property list - QAK */
-if(H5P_DEFAULT == plist_id)
- plist_id = H5P_DATATYPE_CREATE_DEFAULT;
-else
- if(TRUE != H5P_isa_class(plist_id, H5P_DATATYPE_CREATE))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object create property list")
+ /* Find the source object to copy */
+ if(H5G_loc_find(&loc, src_name, &src_loc/*out*/, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found")
+ ent_found = TRUE;
- if(H5G_copy(&src_loc, &dst_loc, name_dst, plist_id) < 0)
+ if(H5O_open(&src_oloc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+ obj_open = TRUE;
+
+ /* Get correct property list */
+ if(H5P_DEFAULT == plist_id)
+ plist_id = H5P_OBJECT_COPY_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(plist_id, H5P_OBJECT_COPY))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list")
+
+ if(H5G_copy(&src_loc, &dst_loc, dst_name, plist_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
done:
+ if(ent_found)
+ H5G_name_free(&src_path);
+ if (obj_open)
+ H5O_close(&src_oloc);
+
FUNC_LEAVE_API(ret_value)
} /* end H5Gcopy() */
@@ -1127,17 +1197,17 @@ done:
static herr_t
H5G_init_interface(void)
{
- H5P_genclass_t *crt_pclass;
+ H5P_genclass_t *crt_pclass, *cpy_pclass;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_init_interface);
/* Initialize the atom group for the group IDs */
- if (H5I_register_type(H5I_GROUP, (size_t)H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
+ if(H5I_register_type(H5I_GROUP, (size_t)H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
(H5I_free_t)H5G_close) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface");
- /* ========== group Creation Property Class Initialization ============*/
+ /* ========== Group Creation Property Class Initialization ============*/
assert(H5P_CLS_GROUP_CREATE_g!=-1);
/* Get the pointer to group creation class */
@@ -1145,12 +1215,26 @@ H5G_init_interface(void)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class")
/* Only register the default property list if it hasn't been created yet */
- if(H5P_LST_GROUP_CREATE_g==(-1)) {
+ if(H5P_LST_GROUP_CREATE_g == (-1)) {
/* Register the default group creation property list */
if((H5P_LST_GROUP_CREATE_g = H5P_create_id(crt_pclass))<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class")
} /* end if */
+ /* ========== Object Copy Property Class Initialization ============*/
+ assert(H5P_CLS_OBJECT_COPY_g!=-1);
+
+ /* Get the pointer to group copy class */
+ if(NULL == (cpy_pclass = H5I_object(H5P_CLS_OBJECT_COPY_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class")
+
+ /* Only register the default property list if it hasn't been created yet */
+ if(H5P_LST_OBJECT_COPY_g == (-1)) {
+ /* Register the default group copy property list */
+ if((H5P_LST_OBJECT_COPY_g = H5P_create_id(cpy_pclass))<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class")
+ } /* end if */
+
done:
FUNC_LEAVE_NOAPI(ret_value);
}
@@ -2888,16 +2972,20 @@ H5G_unmount(H5G_t *grp)
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_copy(H5G_loc_t *src_loc, H5G_loc_t *dst_loc,
- const char *name_dst, hid_t plist_id)
+H5G_copy(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_t plist_id)
{
- H5P_genplist_t *oc_plist; /* Property list created */
+ H5P_genplist_t *gcrt_plist; /* Group create property list created */
+ H5P_genplist_t *gcpy_plist; /* Group copy property list created */
hid_t dxpl_id = H5AC_dxpl_id;
- H5G_name_t new_path; /* Copied object group hier. path */
- H5O_loc_t new_oloc; /* Copied object object location */
+ H5G_name_t new_path; /* Copied object group hier. path */
+ H5O_loc_t new_oloc; /* Copied object object location */
H5G_loc_t new_loc; /* Group location of object copied */
hbool_t entry_inserted = FALSE; /* Flag to indicate that the new entry was inserted into a group */
- herr_t ret_value = SUCCEED; /* Return value */
+ unsigned cpy_option = 0; /* Copy options */
+ H5P_genclass_t *gcrt_class; /* Group creation property class */
+ hid_t gcplist_id = H5P_DEFAULT; /* Group creation property list */
+ hbool_t gcplist_created = FALSE; /* Flag o indicate if group creation property list is created */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_copy, FAIL);
@@ -2905,12 +2993,16 @@ H5G_copy(H5G_loc_t *src_loc, H5G_loc_t *dst_loc,
HDassert(src_loc->oloc->file);
HDassert(dst_loc);
HDassert(dst_loc->oloc->file);
- HDassert(name_dst);
+ HDassert(dst_name);
/* Get the property list */
- if(NULL == (oc_plist = H5I_object(plist_id)))
+ if(NULL == (gcpy_plist = H5I_object(plist_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ /* Retrieve the copy parameters */
+ if(H5P_get(gcpy_plist, H5G_CPY_OPTION_NAME, &cpy_option) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag")
+
/* Set up copied object location to fill in */
new_loc.oloc = &new_oloc;
new_loc.path = &new_path;
@@ -2918,11 +3010,29 @@ H5G_copy(H5G_loc_t *src_loc, H5G_loc_t *dst_loc,
new_oloc.file = dst_loc->oloc->file;
/* copy the object from the source file to the destination file */
- if(H5O_copy_header(src_loc->oloc, &new_oloc, dxpl_id) < 0)
+ if(H5O_copy_header(src_loc->oloc, &new_oloc, dxpl_id, cpy_option) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
+ /* create group creatiion property to create missing groups */
+ if((cpy_option & H5G_COPY_CREATE_INTERMEDIATE_GROUP_FLAG) > 0) {
+ if(NULL == (gcrt_class = H5I_object_verify(H5P_GROUP_CREATE, H5I_GENPROP_CLS)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class");
+
+ /* Create the new property list */
+ if((gcplist_id = H5P_create_id(gcrt_class)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create property list");
+ gcplist_created = TRUE;
+
+ if(H5P_set(gcplist_id, H5G_CRT_INTERMEDIATE_GROUP_NAME, &cpy_option) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set intermediate group creation flag")
+ } else
+ plist_id = H5P_GROUP_CREATE_DEFAULT;
+
+ if(NULL == (gcrt_plist = H5I_object(plist_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+
/* Insert the new object in the destination file's group */
- if(H5G_insert(dst_loc, name_dst, &new_loc, dxpl_id, oc_plist) < 0)
+ if(H5G_insert(dst_loc, dst_name, &new_loc, dxpl_id, gcrt_plist) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert the name")
entry_inserted = TRUE;
@@ -2930,6 +3040,8 @@ done:
/* Free the ID to name buffers */
if(entry_inserted)
H5G_loc_free(&new_loc);
+ if (gcplist_created)
+ H5P_close(gcrt_plist);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_copy() */
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 1f0ae62..1a2f922 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1941,7 +1941,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
/* Copy the shared object from source to destination */
/* (Increments link count on destination) */
- if(H5O_copy_header_map(&src_oloc, &new_oloc, dxpl_id, udata->map_list) < 0)
+ if(H5O_copy_header_map(&src_oloc, &new_oloc, dxpl_id, udata->cpy_option, udata->map_list) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5B_ITER_ERROR, "unable to copy object")
/* Construct link information for eventual insertion */
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index e40e83c..19d1de4 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -228,6 +228,7 @@ typedef struct H5G_bt_it_ud5_t {
H5F_t *dst_file; /* File of destination group */
H5O_stab_t *dst_stab; /* symbol table info for destination group */
H5SL_t *map_list; /* skip list to map copied object addresses */
+ unsigned cpy_option; /* cpy options */
} H5G_bt_it_ud5_t;
/* Typedef for path traversal operations */
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index d05aba0..d3b00e3 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -79,6 +79,12 @@
#define H5G_CRT_INTERMEDIATE_GROUP_SIZE sizeof(unsigned)
#define H5G_CRT_INTERMEDIATE_GROUP_DEF 0
+/* definitions for copying objects */
+#define H5G_CPY_OPTION_NAME "copy object"
+#define H5G_CPY_OPTION_SIZE sizeof(unsigned)
+#define H5G_CPY_OPTION_DEF 0
+
+
/* Type of operation being performed for call to H5G_name_replace() */
typedef enum {
H5G_NAME_MOVE = 0, /* H5*move call */
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index 801b7c3..b9f0095 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -101,6 +101,15 @@ typedef struct H5G_stat_t {
typedef herr_t (*H5G_iterate_t)(hid_t group, const char *name,
void *op_data);
+/* Flags for object copy (H5Gcopy) */
+#define H5G_COPY_CREATE_INTERMEDIATE_GROUP_FLAG (0x0001u) /* Create missing groups when create a group */
+#define H5G_COPY_SHALLOW_HIERARCHY_FLAG (0x0002u) /* Copy only immediate members */
+#define H5G_COPY_EXPAND_SOFT_LINK_FLAG (0x0004u) /* Expand soft links into new objects */
+#define H5G_COPY_EXPAND_EXT_LINK_FLAG (0x0008u) /* Expand external links into new objects */
+#define H5G_COPY_EXPAND_OBJ_REFERENCE_FLAG (0x0010u) /* Copy objects that are pointed by references */
+#define H5G_COPY_WITHOUT_ATTR_FLAG (0x0020u) /* Copy object without copying attributes */
+#define H5G_COPY_ALL (0x003Fu) /* All object copying flags (for internal range checking) */
+
H5_DLL hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint);
H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name);
H5_DLL herr_t H5Gclose(hid_t group_id);
@@ -125,8 +134,8 @@ H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize,
H5_DLL hid_t H5Gcreate_expand(hid_t loc_id, const char *name, hid_t gcpl_id,
hid_t gapl_id);
H5_DLL hid_t H5Gget_create_plist(hid_t group_id);
-H5_DLL herr_t H5Gcopy(hid_t src_id, hid_t dst_loc_id, const char *name_dst,
- hid_t plist_id);
+H5_DLL herr_t H5Gcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
+ const char *dst_name, hid_t plist_id);
#ifdef __cplusplus
}
diff --git a/src/H5O.c b/src/H5O.c
index 1d54077..a52dca6 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -209,10 +209,10 @@ static herr_t H5O_iterate_real(const H5O_loc_t *loc, const H5O_msg_class_t *type
H5AC_protect_t prot, hbool_t internal, void *op, void *op_data, hid_t dxpl_id);
static H5G_obj_t H5O_obj_type_real(H5O_t *oh);
static const H5O_obj_class_t *H5O_obj_class(H5O_t *oh);
-static void * H5O_copy_mesg_file(const H5O_msg_class_t *type, H5F_t *file_src,
- void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
-static herr_t H5O_copy_header_real(const H5O_loc_t *oloc_src,
- H5O_loc_t *oloc_dst /*out */, hid_t dxpl_id, H5SL_t *map_list);
+static void * H5O_copy_mesg_file(const H5O_msg_class_t *type, H5F_t *file_src, void *mesg_src,
+ H5F_t *file_dst, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
+static herr_t H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list);
static herr_t H5O_copy_free_addrmap_cb(void *item, void *key, void *op_data);
@@ -4019,8 +4019,8 @@ H5O_loc_copy(H5O_loc_t *dst, const H5O_loc_t *src, H5_copy_depth_t depth)
*-------------------------------------------------------------------------
*/
static void *
-H5O_copy_mesg_file(const H5O_msg_class_t *type, H5F_t *file_src,
- void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata)
+H5O_copy_mesg_file(const H5O_msg_class_t *type, H5F_t *file_src, void *native_src,
+ H5F_t *file_dst, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata)
{
void *ret_value;
@@ -4034,7 +4034,7 @@ H5O_copy_mesg_file(const H5O_msg_class_t *type, H5F_t *file_src,
HDassert(file_dst);
HDassert(map_list);
- if(NULL == (ret_value = (type->copy_file)(file_src, native_src, file_dst, dxpl_id, map_list, udata)))
+ if(NULL == (ret_value = (type->copy_file)(file_src, native_src, file_dst, dxpl_id, cpy_option, map_list, udata)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message to file")
done:
@@ -4055,21 +4055,21 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_copy_header_real(const H5O_loc_t *oloc_src,
- H5O_loc_t *oloc_dst /*out */, hid_t dxpl_id, H5SL_t *map_list)
+H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list)
{
- H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */
- H5O_t *oh_src = NULL; /* Object header for source object */
- H5O_t *oh_dst = NULL; /* Object header for destination object */
- unsigned chunkno = 0, mesgno = 0;
- size_t hdr_size;
- haddr_t addr_new;
- H5O_mesg_t *mesg_src; /* Message in source object header */
- H5O_mesg_t *mesg_dst; /* Message in source object header */
- const H5O_msg_class_t *copy_type; /* Type of message to use for copying */
- const H5O_obj_class_t *obj_class; /* Type of object we are copying */
- void *udata = NULL; /* User data for passing to message callbacks */
- herr_t ret_value = SUCCEED;
+ H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */
+ H5O_t *oh_src = NULL; /* Object header for source object */
+ H5O_t *oh_dst = NULL; /* Object header for destination object */
+ unsigned chunkno = 0, mesgno = 0;
+ size_t hdr_size;
+ haddr_t addr_new;
+ H5O_mesg_t *mesg_src; /* Message in source object header */
+ H5O_mesg_t *mesg_dst; /* Message in source object header */
+ const H5O_msg_class_t *copy_type; /* Type of message to use for copying */
+ const H5O_obj_class_t *obj_class; /* Type of object we are copying */
+ void *udata = NULL; /* User data for passing to message callbacks */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT(H5O_copy_header_real)
@@ -4099,7 +4099,6 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src,
/* get the size of the file header of the destination file */
hdr_size = H5O_SIZEOF_HDR(oloc_dst->file);
-
/* Allocate the destination object header and fill in header fields */
if(NULL == (oh_dst = H5FL_MALLOC(H5O_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
@@ -4197,7 +4196,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src,
} /* end if (NULL == mesg_src->native) */
/* Perform "pre copy" operation on messge */
- if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, udata) < 0)
+ if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->type, mesg_src->native, udata) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'post copy' operation on message")
} /* end if */
} /* end for */
@@ -4231,12 +4230,12 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src,
/* Copy the source message */
if(H5O_CONT_ID == mesg_src->type->id) {
if((mesg_dst->native = H5O_copy_mesg_file(copy_type, oloc_src->file, mesg_src->native,
- oloc_dst->file, dxpl_id, map_list, oh_dst->chunk)) == NULL)
+ oloc_dst->file, dxpl_id, cpy_option, map_list, oh_dst->chunk)) == NULL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message")
} /* end if */
else {
if((mesg_dst->native = H5O_copy_mesg_file(copy_type, oloc_src->file, mesg_src->native,
- oloc_dst->file, dxpl_id, map_list, udata)) == NULL)
+ oloc_dst->file, dxpl_id, cpy_option, map_list, udata)) == NULL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message")
} /* end else */
@@ -4264,6 +4263,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src,
addr_map->dst_addr = oloc_dst->addr;
addr_map->is_locked = TRUE; /* We've locked the object currently */
addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */
+
if(H5SL_insert(map_list, addr_map, &(addr_map->src_addr)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list")
@@ -4292,7 +4292,8 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src,
LOAD_NATIVE(oloc_dst->file, dxpl_id, mesg_dst, FAIL)
/* Perform "post copy" operation on messge */
- if((copy_type->post_copy_file)(oloc_src->file, mesg_src->native, oloc_dst, mesg_dst->native, &modified, dxpl_id, map_list) < 0)
+ if((copy_type->post_copy_file)(oloc_src->file, mesg_src->native, oloc_dst,
+ mesg_dst->native, &modified, dxpl_id, cpy_option, map_list) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'post copy' operation on message")
/* Mark message and header as dirty if the destination message was modified */
@@ -4353,8 +4354,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_copy_header_map(const H5O_loc_t *oloc_src,
- H5O_loc_t *oloc_dst /*out */, hid_t dxpl_id, H5SL_t *map_list)
+H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list)
{
H5O_addr_map_t *addr_map; /* Address mapping of object copied */
hbool_t inc_link; /* Whether to increment the link count for the object */
@@ -4376,7 +4377,7 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src,
/* Copy object for the first time */
/* Copy object referred to */
- if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, map_list) < 0)
+ if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, cpy_option, map_list) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* When an object is copied for the first time, increment it's link */
@@ -4455,7 +4456,8 @@ H5O_copy_free_addrmap_cb(void *item, void UNUSED *key, void UNUSED *op_data)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, hid_t dxpl_id)
+H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, hid_t dxpl_id,
+ unsigned cpy_option)
{
H5SL_t *map_list = NULL; /* Skip list to hold address mappings */
herr_t ret_value = SUCCEED;
@@ -4472,7 +4474,7 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, hid_t d
HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, FAIL, "cannot make skip list")
/* copy the object from the source file to the destination file */
- if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, map_list) < 0)
+ if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, cpy_option, map_list) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
done:
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 6ee9c40..eefc28b 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -38,7 +38,7 @@ static herr_t H5O_attr_free (void *mesg);
static herr_t H5O_attr_delete (H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
static herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
static void *H5O_attr_copy_file(H5F_t *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
+ H5F_t *file_dst, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
static herr_t H5O_attr_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -653,8 +653,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_attr_copy_file(H5F_t UNUSED *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void UNUSED *udata)
+H5O_attr_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t *file_dst,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void UNUSED *udata)
{
H5A_t *attr_src = (H5A_t *)native_src;
H5A_t *attr_dst = NULL;
@@ -718,7 +718,7 @@ H5O_attr_copy_file(H5F_t UNUSED *file_src, void *native_src,
dst_oloc->file = file_dst;
/* Copy the shared object from source to destination */
- if(H5O_copy_header_map(src_oloc, dst_oloc, dxpl_id, map_list) < 0)
+ if(H5O_copy_header_map(src_oloc, dst_oloc, dxpl_id, cpy_option, map_list) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object")
/* Reset shared message information */
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index 0808384..c4c8af3 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -41,8 +41,8 @@ static herr_t H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static size_t H5O_cont_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_cont_free(void *mesg);
static herr_t H5O_cont_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
-static void *H5O_cont_copy_file(H5F_t *file_src, void *mesg_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
+static void *H5O_cont_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
static herr_t H5O_cont_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -259,8 +259,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_cont_copy_file(H5F_t UNUSED *file_src, void *mesg_src,
- H5F_t UNUSED *file_dst, hid_t UNUSED dxpl_id, H5SL_t UNUSED *map_list, void *udata)
+H5O_cont_copy_file(H5F_t UNUSED *file_src, void *mesg_src, H5F_t UNUSED *file_dst,
+ hid_t UNUSED dxpl_id, UNUSED unsigned cpy_option, H5SL_t UNUSED *map_list, void *udata)
{
H5O_cont_t *cont_src = (H5O_cont_t *) mesg_src;
H5O_chunk_t *chunk = (H5O_chunk_t *)udata;
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index d4962d9..876d190 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -35,8 +35,8 @@ static herr_t H5O_dtype_get_share (H5F_t *f, const void *_mesg,
H5O_shared_t *sh);
static herr_t H5O_dtype_set_share (H5F_t *f, void *_mesg,
const H5O_shared_t *sh);
-static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, void *mesg_src,
- void *_udata);
+static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
+ void *mesg_src, void *_udata);
static herr_t H5O_dtype_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -1216,7 +1216,7 @@ H5O_dtype_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_dtype_pre_copy_file(H5F_t *file_src, void *mesg_src, void *_udata)
+H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type, void *mesg_src, void *_udata)
{
H5T_t *dt_src = (H5T_t *)mesg_src; /* Source datatype */
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index a70a9b2..2fef999 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -33,8 +33,8 @@ static herr_t H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_efl_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_efl_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_efl_reset(void *_mesg);
-static void *H5O_efl_copy_file(H5F_t *file_src, void *mesg_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
+static void *H5O_efl_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
static herr_t H5O_efl_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -435,8 +435,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_efl_copy_file(H5F_t UNUSED *file_src, void *mesg_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t UNUSED *map_list, void UNUSED *_udata)
+H5O_efl_copy_file(H5F_t UNUSED *file_src, void *mesg_src, H5F_t *file_dst,
+ hid_t dxpl_id, UNUSED unsigned cpy_option, H5SL_t UNUSED *map_list, void UNUSED *_udata)
{
H5O_efl_t *efl_src = (H5O_efl_t *) mesg_src;
H5O_efl_t *efl_dst = NULL;
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 7e6e4f5..ffebfc6 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -39,8 +39,8 @@ static size_t H5O_layout_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_layout_reset(void *_mesg);
static herr_t H5O_layout_free(void *_mesg);
static herr_t H5O_layout_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
-static void *H5O_layout_copy_file(H5F_t *file_src, void *mesg_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
+static void *H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
static herr_t H5O_layout_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -621,8 +621,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_layout_copy_file(H5F_t *file_src, void *mesg_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t UNUSED *map_list, void *_udata)
+H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hid_t dxpl_id,
+ UNUSED unsigned cpy_option, H5SL_t UNUSED *map_list, void *_udata)
{
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
H5O_layout_t *layout_src = (H5O_layout_t *) mesg_src;
diff --git a/src/H5Olink.c b/src/H5Olink.c
index d9c84c7..88ccabc 100644
--- a/src/H5Olink.c
+++ b/src/H5Olink.c
@@ -43,9 +43,9 @@ static herr_t H5O_link_reset(void *_mesg);
static herr_t H5O_link_free(void *_mesg);
static herr_t H5O_link_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
static void *H5O_link_copy_file(H5F_t *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
-static herr_t H5O_link_post_copy_file(H5F_t *file_src, const void *mesg_src,
- H5O_loc_t *dst_oloc, void *mesg_dst, hbool_t *modified, hid_t dxpl_id, H5SL_t *map_list);
+ H5F_t *file_dst, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
+static herr_t H5O_link_post_copy_file(H5F_t *file_src, const void *mesg_src, H5O_loc_t *dst_oloc,
+ void *mesg_dst, hbool_t *modified, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list);
static herr_t H5O_link_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -476,8 +476,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_link_copy_file(H5F_t UNUSED *file_src, void *native_src,
- H5F_t UNUSED *file_dst, hid_t UNUSED dxpl_id, H5SL_t UNUSED *map_list, void UNUSED *udata)
+H5O_link_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t UNUSED *file_dst,
+hid_t UNUSED dxpl_id, UNUSED unsigned cpy_option, H5SL_t UNUSED *map_list, void UNUSED *udata)
{
H5O_link_t *link_src = (H5O_link_t *) native_src;
H5O_link_t *link_dst = NULL;
@@ -542,8 +542,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_link_post_copy_file(H5F_t *file_src, const void *mesg_src,
- H5O_loc_t *dst_oloc, void *mesg_dst, hbool_t *modified, hid_t dxpl_id, H5SL_t *map_list)
+H5O_link_post_copy_file(H5F_t *file_src, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst,
+ hbool_t *modified, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list)
{
const H5O_link_t *link_src = (const H5O_link_t *)mesg_src;
H5O_link_t *link_dst = (H5O_link_t *)mesg_dst;
@@ -580,7 +580,7 @@ H5O_link_post_copy_file(H5F_t *file_src, const void *mesg_src,
/* Copy the shared object from source to destination */
/* (Increments link count on destination) */
- if(H5O_copy_header_map(&src_oloc, &new_oloc, dxpl_id, map_list) < 0)
+ if(H5O_copy_header_map(&src_oloc, &new_oloc, dxpl_id, cpy_option, map_list) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Update link information with new destination object's address */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 0ce644b..ec453f7 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -73,9 +73,9 @@ struct H5O_msg_class_t {
herr_t (*link)(H5F_t *, hid_t, const void *); /* Increment any links in file reference by this message */
herr_t (*get_share)(H5F_t*, const void*, struct H5O_shared_t*); /* Get shared information */
herr_t (*set_share)(H5F_t*, void*, const struct H5O_shared_t*); /* Set shared information */
- herr_t (*pre_copy_file)(H5F_t *, void *, void *); /*"pre copy" action when copying native value to file */
- void *(*copy_file)(H5F_t *, void *, H5F_t *, hid_t, H5SL_t *, void *); /*copy native value to file */
- herr_t (*post_copy_file)(H5F_t *, const void *, H5O_loc_t *, void *, hbool_t *, hid_t, H5SL_t *); /*"post copy" action when copying native value to file */
+ herr_t (*pre_copy_file)(H5F_t *, const H5O_msg_class_t *, void *, void *); /*"pre copy" action when copying native value to file */
+ void *(*copy_file)(H5F_t *, void *, H5F_t *, hid_t, unsigned, H5SL_t *, void *); /*copy native value to file */
+ herr_t (*post_copy_file)(H5F_t *, const void *, H5O_loc_t *, void *, hbool_t *, hid_t, unsigned, H5SL_t *); /*"post copy" action when copying native value to file */
herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int);
};
diff --git a/src/H5Opline.c b/src/H5Opline.c
index d6e9870..7746987 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -36,8 +36,8 @@ static void *H5O_pline_copy (const void *_mesg, void *_dest, unsigned update_fla
static size_t H5O_pline_size (const H5F_t *f, const void *_mesg);
static herr_t H5O_pline_reset (void *_mesg);
static herr_t H5O_pline_free (void *_mesg);
-static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, void *mesg_src,
- void *_udata);
+static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
+ void *mesg_src, void *_udata);
static herr_t H5O_pline_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -441,7 +441,7 @@ H5O_pline_free (void *mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_pline_pre_copy_file(H5F_t *file_src, void *mesg_src, void *_udata)
+H5O_pline_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type, void *mesg_src, void *_udata)
{
H5O_pline_t *pline_src = (H5O_pline_t *)mesg_src; /* Source datatype */
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index b257e98..c087fe1 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -336,10 +336,10 @@ H5_DLL herr_t H5O_get_info(H5O_loc_t *loc, H5O_stat_t *ostat, hid_t dxpl_id);
H5_DLL herr_t H5O_iterate(const H5O_loc_t *loc, unsigned type_id, H5O_operator_t op,
void *op_data, hid_t dxpl_id);
H5_DLL H5G_obj_t H5O_obj_type(H5O_loc_t *loc, hid_t dxpl_id);
-H5_DLL herr_t H5O_copy_header(const H5O_loc_t *oloc_src,
- H5O_loc_t *oloc_dst /*out */, hid_t dxpl_id);
-H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src,
- H5O_loc_t *oloc_dst /*out */, hid_t dxpl_id, struct H5SL_t *map_list);
+H5_DLL herr_t H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
+ hid_t dxpl_id, unsigned cpy_option);
+H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
+ hid_t dxpl_id, unsigned cpy_option, struct H5SL_t *map_list);
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);
H5_DLL herr_t H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
int fwidth);
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index cdba678..ccdb61c 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -42,8 +42,10 @@ static void *H5O_shared_copy(const void *_mesg, void *_dest, unsigned update_fla
static size_t H5O_shared_size (const H5F_t*, const void *_mesg);
static herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
static herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
+static herr_t H5O_shared_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
+ void *mesg_src, void *_udata);
static void *H5O_shared_copy_file(H5F_t *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
+ H5F_t *file_dst, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
static herr_t H5O_shared_debug (H5F_t*, hid_t dxpl_id, const void*, FILE*, int, int);
/* This message derives from H5O message class */
@@ -61,7 +63,7 @@ const H5O_msg_class_t H5O_MSG_SHARED[1] = {{
H5O_shared_link, /*link method */
NULL, /*get share method */
NULL, /*set share method */
- NULL, /* pre copy native value to file */
+ H5O_shared_pre_copy_file, /* pre copy native value to file */
H5O_shared_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
H5O_shared_debug /*debug method */
@@ -426,8 +428,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_shared_copy_file(H5F_t UNUSED *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void UNUSED *udata)
+H5O_shared_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t *file_dst,
+ hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void UNUSED *udata)
{
H5O_shared_t *shared_src = (H5O_shared_t *)native_src;
H5O_shared_t *shared_dst = NULL;
@@ -449,7 +451,7 @@ H5O_shared_copy_file(H5F_t UNUSED *file_src, void *native_src,
shared_dst->oloc.file = file_dst;
/* Copy the shared object from source to destination */
- if(H5O_copy_header_map(&(shared_src->oloc), &(shared_dst->oloc), dxpl_id, map_list) < 0)
+ if(H5O_copy_header_map(&(shared_src->oloc), &(shared_dst->oloc), dxpl_id, cpy_option, map_list) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object")
/* Set return value */
@@ -465,6 +467,52 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_shared_pre_copy_file
+ *
+ * Purpose: Perform any necessary actions before copying message between
+ * files for shared messages.
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Peter Cao
+ * Saturday, February 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_shared_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type, void *native_src, void *udata)
+{
+ H5O_shared_t *shared_src = (H5O_shared_t *)native_src;
+ void *mesg_native = NULL;
+ hid_t dxpl_id = H5AC_dxpl_id;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_pre_copy_file)
+
+ if(type->pre_copy_file) {
+ if((mesg_native = H5O_read_real(&(shared_src->oloc), type, 0, NULL, dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to load object header")
+
+ /* Perform "pre copy" operation on messge */
+ if((type->pre_copy_file)(file_src, type, mesg_native, udata) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'pre copy' operation on message")
+ } /* end of if */
+
+ /* check args */
+ HDassert(file_src);
+ HDassert(type);
+
+done:
+ if(mesg_native)
+ H5O_free_real(type, mesg_native);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_shared_pre_copy_file() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_shared_debug
*
* Purpose: Prints debugging info for the message
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index f1e8a25..241bd94 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -44,9 +44,9 @@ static size_t H5O_stab_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_stab_free(void *_mesg);
static herr_t H5O_stab_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
static void *H5O_stab_copy_file(H5F_t *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t *map_list, void *udata);
-static herr_t H5O_stab_post_copy_file(H5F_t *file_src, const void *mesg_src,
- H5O_loc_t *dst_oloc, void *mesg_dst, hbool_t *modified, hid_t dxpl_id, H5SL_t *map_list);
+ H5F_t *file_dst, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list, void *udata);
+static herr_t H5O_stab_post_copy_file(H5F_t *file_src, const void *mesg_src, H5O_loc_t *dst_oloc,
+ void *mesg_dst, hbool_t *modified, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list);
static herr_t H5O_stab_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -311,8 +311,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_stab_copy_file(H5F_t *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5SL_t UNUSED *map_list, void UNUSED *udata)
+H5O_stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst,
+ hid_t dxpl_id, UNUSED unsigned cpy_option, H5SL_t UNUSED *map_list, void UNUSED *udata)
{
H5O_stab_t *stab_src = (H5O_stab_t *) native_src;
H5O_stab_t *stab_dst = NULL;
@@ -362,8 +362,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_stab_post_copy_file(H5F_t *file_src, const void *mesg_src,
- H5O_loc_t *dst_oloc, void *mesg_dst, hbool_t UNUSED *modified, hid_t dxpl_id, H5SL_t *map_list)
+H5O_stab_post_copy_file(H5F_t *file_src, const void *mesg_src, H5O_loc_t *dst_oloc,
+void *mesg_dst, hbool_t UNUSED *modified, hid_t dxpl_id, unsigned cpy_option, H5SL_t *map_list)
{
H5G_bt_it_ud5_t udata; /* B-tree user data */
const H5O_stab_t *stab_src = (const H5O_stab_t *)mesg_src;
@@ -385,6 +385,7 @@ H5O_stab_post_copy_file(H5F_t *file_src, const void *mesg_src,
udata.src_heap_addr = stab_src->heap_addr;
udata.dst_file = dst_oloc->file;
udata.dst_stab = stab_dst;
+ udata.cpy_option = cpy_option;
/* Iterate over objects in group, copying them */
if((H5B_iterate(file_src, dxpl_id, H5B_SNODE, H5G_node_copy, stab_src->btree_addr, &udata)) < 0)
diff --git a/src/H5P.c b/src/H5P.c
index e31a23e..c28bd44 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -54,7 +54,8 @@ hid_t H5P_CLS_GROUP_CREATE_g = FAIL;
hid_t H5P_CLS_GROUP_ACCESS_g = FAIL;
hid_t H5P_CLS_DATATYPE_CREATE_g = FAIL;
hid_t H5P_CLS_DATATYPE_ACCESS_g = FAIL;
-hid_t H5P_CLS_ATTRIBUTE_CREATE_g = FAIL;
+hid_t H5P_CLS_ATTRIBUTE_CREATE_g = FAIL;
+hid_t H5P_CLS_OBJECT_COPY_g = FAIL;
/*
* Predefined property lists for each predefined class. These are initialized
@@ -69,9 +70,10 @@ hid_t H5P_LST_DATASET_XFER_g = FAIL;
hid_t H5P_LST_MOUNT_g = FAIL;
hid_t H5P_LST_GROUP_CREATE_g = FAIL;
hid_t H5P_LST_GROUP_ACCESS_g = FAIL;
-hid_t H5P_LST_DATATYPE_CREATE_g = FAIL;
-hid_t H5P_LST_DATATYPE_ACCESS_g = FAIL;
-hid_t H5P_LST_ATTRIBUTE_CREATE_g = FAIL;
+hid_t H5P_LST_DATATYPE_CREATE_g = FAIL;
+hid_t H5P_LST_DATATYPE_ACCESS_g = FAIL;
+hid_t H5P_LST_ATTRIBUTE_CREATE_g = FAIL;
+hid_t H5P_LST_OBJECT_COPY_g = FAIL;
/* Track the revision count of a class, to make comparisons faster */
static unsigned H5P_next_rev=0;
@@ -240,6 +242,12 @@ H5P_init_interface(void)
*/
H5P_genclass_t *ocrt_class; /* Pointer to object (dataset, group, or datatype) creation property list class created */
unsigned intmd_group = H5G_CRT_INTERMEDIATE_GROUP_DEF;
+ /* Object copy property class variables. In sequence, they are,
+ * - Copy property list class to modify
+ * - Default value for "object copy parameters"
+ */
+ H5P_genclass_t *ocpy_class; /* Pointer to group copying property list class */
+ unsigned ocpy_option = H5G_CPY_OPTION_DEF;
size_t nprops; /* Number of properties */
herr_t ret_value = SUCCEED;
@@ -263,18 +271,18 @@ H5P_init_interface(void)
/* Register the root class */
if ((H5P_CLS_NO_CLASS_g = H5I_register (H5I_GENPROP_CLS, root_class))<0)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class")
/* Create object property class */
/* Allocate the object class */
assert(H5P_CLS_OBJECT_CREATE_g==(-1));
if (NULL==(ocrt_class = H5P_create_class (root_class,"object create",1,NULL,NULL,NULL,NULL,NULL,NULL)))
- HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed")
/* Register the object class */
if ((H5P_CLS_OBJECT_CREATE_g = H5I_register (H5I_GENPROP_CLS, ocrt_class))<0)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class")
/* Get the number of properties in the object class */
if(H5P_get_nprops_pclass(ocrt_class,&nprops,FALSE)<0)
@@ -288,6 +296,29 @@ H5P_init_interface(void)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
} /* end if */
+ /* Create object copy property class */
+
+ /* Allocate the object copy class */
+ HDassert(H5P_CLS_OBJECT_COPY_g == (-1));
+ if(NULL == (ocpy_class = H5P_create_class(root_class, "object copy", 1, NULL, NULL, NULL, NULL, NULL, NULL)))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed")
+
+ /* Register the object copy class */
+ if((H5P_CLS_OBJECT_COPY_g = H5I_register(H5I_GENPROP_CLS, ocpy_class)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class")
+
+ /* Get the number of properties in the class */
+ if(H5P_get_nprops_pclass(ocpy_class, &nprops, FALSE) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties")
+
+ /* Assume that if there are properties in the class, they are the default ones */
+ if(nprops == 0) {
+ /* Register group info */
+ if(H5P_register(ocpy_class, H5G_CPY_OPTION_NAME, H5G_CPY_OPTION_SIZE,
+ &ocpy_option, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ } /* end if */
+
/* Register the group creation and group access property classes */
/* (Register the group property classes before file property classes, so
* file creation property class can inherit from group creation property
@@ -473,6 +504,7 @@ H5P_term_interface(void)
H5P_LST_DATATYPE_CREATE_g =
H5P_LST_DATATYPE_ACCESS_g =
H5P_LST_ATTRIBUTE_CREATE_g =
+ H5P_LST_OBJECT_COPY_g =
H5P_LST_MOUNT_g = (-1);
} /* end if */
} /* end if */
@@ -495,6 +527,7 @@ H5P_term_interface(void)
H5P_CLS_DATATYPE_CREATE_g =
H5P_CLS_DATATYPE_ACCESS_g =
H5P_CLS_ATTRIBUTE_CREATE_g =
+ H5P_CLS_OBJECT_COPY_g =
H5P_CLS_MOUNT_g = (-1);
} /* end if */
} /* end if */
diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c
index 8d146bf..e0bf371 100755
--- a/src/H5Pocpl.c
+++ b/src/H5Pocpl.c
@@ -31,7 +31,20 @@
* Purpose: set crt_intmd_group so that H5Gcreate(), H5Dcreate, etc.
* will create missing groups along the given path "name"
*
+ * Usage: H5Pset_create_intermediate_group(plist_id, crt_intmd_group)
+ * hid_t plist_id; IN: Property list to create a new group
+ * unsigned crt_intmd_group; IN: Flag to create intermediate group
+ * positive value -- to create intermediate group
+ * otherwise -- do not create intermediate group
+ * For example, H5Pset_create_intermediate_group(plist_id, 1) to create intermediate group;
+ *
* Note: XXX: This property should really be an access property. -QAK
+ * XXX: The property is used only at creation time. It should
+ * be a creation property. However, the property is not
+ * saved with the group. In that sense, it should be access
+ * property. We do not have a good solution for this kind
+ * of property. For now, it is used as a creation property.
+ * -PXC
*
* Return: Non-negative on success/Negative on failure
*
@@ -96,3 +109,83 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_create_intermediate_group() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_copy_object
+ *
+ * Purpose: Set properties when copying an object (group, dataset, and datatype)
+ * from one location to another
+ *
+ * Usage: H5Pset_copy_group(plist_id, cpy_option)
+ * hid_t plist_id; IN: Property list to copy object
+ * unsigned cpy_option; IN: Options to copy object such as
+ * H5G_COPY_SHALLOW_HIERARCHY_FLAG -- Copy only immediate members
+ * H5G_COPY_EXPAND_SOFT_LINK_FLAG -- Expand soft links into new objects/
+ * H5G_COPY_EXPAND_EXT_LINK_FLAG -- Expand external links into new objects
+ * H5G_COPY_EXPAND_OBJ_REFERENCE_FLAG -- Copy objects that are pointed by references
+ * H5G_COPY_WITHOUT_ATTR_FLAG -- Copy object without copying attributes
+*
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Peter Cao
+ * March 13, 2006
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_copy_object(hid_t plist_id, unsigned cpy_option)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(H5Pset_copy_object, FAIL)
+
+ /* Check parameters */
+ if(cpy_option & ~H5G_COPY_ALL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown option specified")
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Set value */
+ if(H5P_set(plist, H5G_CPY_OPTION_NAME, &cpy_option) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set copy object flag")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_copy_object() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_copy_object
+ *
+ * Purpose: Returns the cpy_option, which is set for H5Gcopy(hid_t loc_id,
+ * const char* name, ... ) for copying objects
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Peter Cao
+ * March 13, 2006
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_copy_object(hid_t plist_id, unsigned *cpy_option /*out*/)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(H5Pget_copy_object, FAIL)
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Get values */
+ if(cpy_option)
+ if(H5P_get(plist, H5G_CPY_OPTION_NAME, cpy_option) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_copy_object() */
+
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index bb8525b..aec051c 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -93,6 +93,7 @@ typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data);
#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_g)
#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_g)
#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_g)
+#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_g)
H5_DLLVAR hid_t H5P_CLS_NO_CLASS_g;
H5_DLLVAR hid_t H5P_CLS_OBJECT_CREATE_g;
H5_DLLVAR hid_t H5P_CLS_FILE_CREATE_g;
@@ -106,6 +107,7 @@ H5_DLLVAR hid_t H5P_CLS_GROUP_ACCESS_g;
H5_DLLVAR hid_t H5P_CLS_DATATYPE_CREATE_g;
H5_DLLVAR hid_t H5P_CLS_DATATYPE_ACCESS_g;
H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_g;
+H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_g;
/*
* The library created default property lists
@@ -126,6 +128,7 @@ H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_g;
#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_g)
#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_g)
#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_g)
+#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_g)
H5_DLLVAR hid_t H5P_LST_NO_CLASS_g;
H5_DLLVAR hid_t H5P_LST_FILE_CREATE_g;
H5_DLLVAR hid_t H5P_LST_FILE_ACCESS_g;
@@ -138,6 +141,7 @@ H5_DLLVAR hid_t H5P_LST_GROUP_ACCESS_g;
H5_DLLVAR hid_t H5P_LST_DATATYPE_CREATE_g;
H5_DLLVAR hid_t H5P_LST_DATATYPE_ACCESS_g;
H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_g;
+H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_g;
/* Public functions */
H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name,
@@ -346,6 +350,9 @@ H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /*
H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding);
H5_DLL herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/);
+H5_DLL herr_t H5Pset_copy_object(hid_t plist_id, unsigned crt_intmd);
+H5_DLL herr_t H5Pget_copy_object(hid_t plist_id, unsigned *crt_intmd /*out*/);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/H5T.c b/src/H5T.c
index d3c745a..2a1295e 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -5275,6 +5275,12 @@ H5T_debug(const H5T_t *dt, FILE *stream)
}
fprintf(stream, "\n");
+ } else if (H5T_VLEN==dt->shared->type) {
+ /* Variable data type */
+ fprintf(stream, " VLEN ");
+ H5T_debug(dt->shared->parent, stream);
+ fprintf(stream, "\n");
+
} else if (H5T_ENUM==dt->shared->type) {
/* Enumeration data type */
fprintf(stream, " ");
diff --git a/test/objcopy.c b/test/objcopy.c
index f64f8c8..579beac 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -44,6 +44,7 @@ const char *FILENAME[] = {
#define NAME_DATASET_MULTI_OHDR "dataset_multi_ohdr"
#define NAME_DATASET_MULTI_OHDR2 "dataset_multi_ohdr2"
#define NAME_DATASET_VL "dataset_vl"
+#define NAME_DATASET_VL_VL "dataset_vl_vl"
#define NAME_DATASET_SUB_SUB "/g0/g00/g000/dataset_simple"
#define NAME_GROUP_UNCOPIED "/uncopied"
#define NAME_GROUP_EMPTY "/empty"
@@ -63,7 +64,7 @@ const char *FILENAME[] = {
#define NAME_LINK_SOFT_DANGLE "/g_links/soft_link_to_nowhere"
#define NAME_BUF_SIZE 1024
-#define NUM_ATTRIBUTES 8
+#define NUM_ATTRIBUTES 4
#define ATTR_NAME_LEN 40
#define DIM_SIZE_1 12
#define DIM_SIZE_2 6
@@ -73,6 +74,8 @@ const char *FILENAME[] = {
#define NUM_WIDE_LOOP_GROUPS 10
#define NUM_DATASETS 10
+char src_obj_full_name[215]; /* the full path + name of the object to be copied */
+
/* Table containing object id and object name */
/* (Used for detecting duplicate objects when comparing groups */
static struct {
@@ -673,7 +676,7 @@ compare_datasets(hid_t did, hid_t did2, const void *wbuf)
/* Check that the space used is the same */
/* (Don't check if the dataset is filtered (i.e. compressed, etc.) and
- * the datatype is variable-length, since the addresses for the vlen
+ * the datatype is VLEN, since the addresses for the vlen
* data in each dataset will (probably) be different and the storage
* size will thus vary)
*/
@@ -942,12 +945,12 @@ test_copy_named_datatype(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the datatype from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the datatype for copy */
if ( (tid = H5Topen(fid_src, NAME_DATATYPE_SIMPLE)) < 0) TEST_ERROR;
- /* copy the datatype from SRC to DST */
- if ( H5Gcopy(tid, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the copied datatype */
if ( (tid2 = H5Topen(fid_dst, NAME_DATATYPE_SIMPLE)) < 0) TEST_ERROR;
@@ -1035,12 +1038,12 @@ test_copy_named_datatype_vl(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the datatype from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATATYPE_VL, fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the datatype for copy */
if ( (tid = H5Topen(fid_src, NAME_DATATYPE_VL)) < 0) TEST_ERROR;
- /* copy the datatype from SRC to DST */
- if ( H5Gcopy(tid, fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the copied datatype */
if ( (tid2 = H5Topen(fid_dst, NAME_DATATYPE_VL)) < 0) TEST_ERROR;
@@ -1134,12 +1137,12 @@ test_copy_named_datatype_vl_vl(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the datatype from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATATYPE_VL_VL, fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the datatype for copy */
if ( (tid = H5Topen(fid_src, NAME_DATATYPE_VL_VL)) < 0) TEST_ERROR;
- /* copy the datatype from SRC to DST */
- if ( H5Gcopy(tid, fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the copied datatype */
if ( (tid2 = H5Topen(fid_dst, NAME_DATATYPE_VL_VL)) < 0) TEST_ERROR;
@@ -1251,12 +1254,12 @@ test_copy_dataset_simple(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
@@ -1358,12 +1361,12 @@ test_copy_dataset_simple_empty(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
@@ -1488,12 +1491,12 @@ test_copy_dataset_compound(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_COMPOUND, fid_dst, NAME_DATASET_COMPOUND, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_COMPOUND)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_COMPOUND, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_COMPOUND)) < 0) TEST_ERROR;
@@ -1616,12 +1619,12 @@ test_copy_dataset_chunked(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
@@ -1733,12 +1736,12 @@ test_copy_dataset_chunked_empty(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
@@ -1871,12 +1874,12 @@ test_copy_dataset_chunked_sparse(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
@@ -2004,12 +2007,12 @@ test_copy_dataset_compressed(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
@@ -2132,12 +2135,12 @@ test_copy_dataset_compact(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_COMPACT, fid_dst, NAME_DATASET_COMPACT, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_COMPACT)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_COMPACT, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_COMPACT)) < 0) TEST_ERROR;
@@ -2266,12 +2269,12 @@ test_copy_dataset_external(hid_t fapl)
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
#endif /* 0 */
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_EXTERNAL, fid_dst, NAME_DATASET_EXTERNAL, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_EXTERNAL)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_EXTERNAL, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_EXTERNAL)) < 0) TEST_ERROR;
@@ -2387,12 +2390,12 @@ test_copy_dataset_named_dtype(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_NAMED_DTYPE, fid_dst, NAME_DATASET_NAMED_DTYPE, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_NAMED_DTYPE)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_NAMED_DTYPE, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_NAMED_DTYPE)) < 0) TEST_ERROR;
@@ -2524,12 +2527,12 @@ test_copy_dataset_named_dtype_hier(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -2663,12 +2666,12 @@ test_copy_dataset_named_dtype_hier_outside(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -2797,12 +2800,12 @@ test_copy_dataset_multi_ohdr_chunks(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -2938,12 +2941,12 @@ test_copy_dataset_attr_named_dtype(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -2983,7 +2986,7 @@ error:
/*-------------------------------------------------------------------------
* Function: test_copy_dataset_contig_vl
*
- * Purpose: Create a contiguous dataset w/variable-length datatype in SRC
+ * Purpose: Create a contiguous dataset w/VLEN datatype in SRC
* file and copy it to DST file
*
* Return: Success: 0
@@ -3007,7 +3010,7 @@ test_copy_dataset_contig_vl(hid_t fapl)
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
- TESTING("H5Gcopy(): contiguous dataset with variable-length datatype");
+ TESTING("H5Gcopy(): contiguous dataset with VLEN datatype");
/* set initial data values */
for(i = 0; i < DIM_SIZE_1; i++) {
@@ -3058,12 +3061,12 @@ test_copy_dataset_contig_vl(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
@@ -3112,7 +3115,7 @@ error:
/*-------------------------------------------------------------------------
* Function: test_copy_dataset_chunked_vl
*
- * Purpose: Create a chunked dataset w/variable-length datatype in SRC
+ * Purpose: Create a chunked dataset w/VLEN datatype in SRC
* file and copy it to DST file
*
* Return: Success: 0
@@ -3138,7 +3141,7 @@ test_copy_dataset_chunked_vl(hid_t fapl)
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
- TESTING("H5Gcopy(): chunked dataset with variable-length datatype");
+ TESTING("H5Gcopy(): chunked dataset with VLEN datatype");
/* set initial data values */
for(i = 0; i < DIM_SIZE_1; i++) {
@@ -3196,12 +3199,12 @@ test_copy_dataset_chunked_vl(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
@@ -3250,7 +3253,7 @@ error:
/*-------------------------------------------------------------------------
* Function: test_copy_dataset_compact_vl
*
- * Purpose: Create a compact dataset w/variable-length datatype in SRC
+ * Purpose: Create a compact dataset w/VLEN datatype in SRC
* file and copy it to DST file
*
* Return: Success: 0
@@ -3275,7 +3278,7 @@ test_copy_dataset_compact_vl(hid_t fapl)
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
- TESTING("H5Gcopy(): compact dataset with variable-length datatype");
+ TESTING("H5Gcopy(): compact dataset with VLEN datatype");
/* set initial data values */
for(i = 0; i < DIM_SIZE_1; i++) {
@@ -3333,12 +3336,12 @@ test_copy_dataset_compact_vl(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
@@ -3453,12 +3456,12 @@ test_copy_attribute_vl(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
@@ -3502,7 +3505,7 @@ error:
/*-------------------------------------------------------------------------
* Function: test_copy_dataset_compressed_vl
*
- * Purpose: Create a compressed, chunked, variable-length dataset in SRC
+ * Purpose: Create a compressed, chunked, VLEN dataset in SRC
* file and copy it to DST file
*
* Return: Success: 0
@@ -3530,7 +3533,7 @@ test_copy_dataset_compressed_vl(hid_t fapl)
char dst_filename[NAME_BUF_SIZE];
#endif /* H5_HAVE_FILTER_DEFLATE */
- TESTING("H5Gcopy(): compressed dataset with variable-length datatype");
+ TESTING("H5Gcopy(): compressed dataset with VLEN datatype");
#ifndef H5_HAVE_FILTER_DEFLATE
SKIPPED();
@@ -3596,12 +3599,12 @@ test_copy_dataset_compressed_vl(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset for copy */
if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR;
@@ -3707,12 +3710,12 @@ test_copy_group_empty(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_EMPTY, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_EMPTY)) < 0) TEST_ERROR;
- /* copy the group from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_EMPTY)) < 0) TEST_ERROR;
@@ -3838,12 +3841,12 @@ test_copy_group(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the group from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -3980,12 +3983,12 @@ test_copy_group_deep(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the group from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -4091,12 +4094,12 @@ test_copy_group_loop(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the group from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -4220,12 +4223,12 @@ test_copy_group_wide_loop(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
- /* copy the group from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
@@ -4353,12 +4356,12 @@ test_copy_group_links(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the group for copy */
if ( (gid = H5Gopen(fid_src, NAME_GROUP_LINK)) < 0) TEST_ERROR;
- /* copy the group from SRC to DST */
- if ( H5Gcopy(gid, fid_dst, NAME_GROUP_LINK, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination group */
if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_LINK)) < 0) TEST_ERROR;
@@ -4478,12 +4481,12 @@ test_copy_soft_link(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_LINK_SOFT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+
/* open the dataset through the soft link for copy */
if ( (did = H5Dopen(fid_src, NAME_LINK_SOFT)) < 0) TEST_ERROR;
- /* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
-
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
@@ -4597,21 +4600,15 @@ test_copy_exist(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
- /* open the dataset for copy */
- if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
-
/* copy the dataset from SRC to DST */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+ if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE,fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
/* try to copy the dataset from SRC to DST again (should fail) */
H5E_BEGIN_TRY {
- ret = H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT);
+ ret = H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT);
} H5E_END_TRY;
if( ret >= 0) TEST_ERROR;
- /* close the source dataset */
- if ( H5Dclose(did) < 0) TEST_ERROR;
-
/* close the SRC file */
if ( H5Fclose(fid_src) < 0) TEST_ERROR;
@@ -4712,12 +4709,9 @@ test_copy_path(hid_t fapl)
/* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
- /* open the dataset for copy */
- if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
-
/* copy the dataset from SRC to DST (should fail - intermediate groups not there) */
H5E_BEGIN_TRY {
- ret = H5Gcopy(did, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT);
+ ret = H5Gcopy(fid_src, NAME_DATASET_SUB_SUB, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT);
} H5E_END_TRY;
if( ret >= 0) TEST_ERROR;
@@ -4732,7 +4726,10 @@ test_copy_path(hid_t fapl)
if ( H5Gclose(gid) < 0) TEST_ERROR;
/* copy the dataset from SRC to DST, using full path */
- if ( H5Gcopy(did, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) TEST_ERROR;
+ if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
/* open the destination dataset */
if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_SUB_SUB)) < 0) TEST_ERROR;
@@ -4807,7 +4804,7 @@ test_copy_same_file_named_datatype(hid_t fapl)
/* copy the datatype from SRC to DST */
- if ( H5Gcopy(tid, fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT) < 0) TEST_ERROR;
+ if ( H5Gcopy(fid, NAME_DATATYPE_SIMPLE, fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT) < 0) TEST_ERROR;
/* open the copied datatype */
if ( (tid2 = H5Topen(fid, NAME_DATATYPE_SIMPLE2)) < 0) TEST_ERROR;
@@ -4862,6 +4859,1370 @@ test_copy_mount(hid_t fapl)
/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_compact_named_vl
+ *
+ * Purpose: Create a dataset that uses a named variable length datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, February 4, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_compact_named_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid_copy=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): compact dataset with named VLEN datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].len = i+1;
+ buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
+ for(j = 0; j < buf[i].len; j++)
+ ((int *)buf[i].p)[j] = i*10+j;
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* make a copy of the datatype for later use */
+ if ( (tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR;
+
+ /* named data type */
+ if ( (H5Tcommit(fid_src, NAME_DATATYPE_VL, tid)) < 0) TEST_ERROR;
+
+ /* create and set compact plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ( H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL, tid, sid, pid)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close compact plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
+
+ /* close the datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid_copy) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(pid);
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid_copy);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_compact_named_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_contig_named_vl
+ *
+ * Purpose: Create a dataset that uses a named variable length datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, February 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_contig_named_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid_copy=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): contigous dataset with named VLEN datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].len = i+1;
+ buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
+ for(j = 0; j < buf[i].len; j++)
+ ((int *)buf[i].p)[j] = i*10+j;
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* make a copy of the datatype for later use */
+ if ( (tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR;
+
+ /* named data type */
+ if ( (H5Tcommit(fid_src, NAME_DATATYPE_VL, tid)) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close the datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid_copy) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid_copy);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_contig_named_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_chunked_named_vl
+ *
+ * Purpose: Create a dataset that uses a named variable length datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, February 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_chunked_named_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid_copy=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): chunked dataset with named VLEN datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].len = i+1;
+ buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
+ for(j = 0; j < buf[i].len; j++)
+ ((int *)buf[i].p)[j] = i*10+j;
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* make a copy of the datatype for later use */
+ if ( (tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR;
+
+ /* named data type */
+ if ( (H5Tcommit(fid_src, NAME_DATATYPE_VL, tid)) < 0) TEST_ERROR;
+
+ /* create and set chunk plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ( H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL, tid, sid, pid)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close compact plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
+
+ /* close the datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid_copy) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(pid);
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid_copy);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_chunked_named_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_compressed_named_vl
+ *
+ * Purpose: Create a dataset that uses a named variable length datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, February 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_compressed_named_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid_copy=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): compressed dataset with named VLEN datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].len = i+1;
+ buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
+ for(j = 0; j < buf[i].len; j++)
+ ((int *)buf[i].p)[j] = i*10+j;
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* make a copy of the datatype for later use */
+ if ( (tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR;
+
+ /* named data type */
+ if ( (H5Tcommit(fid_src, NAME_DATATYPE_VL, tid)) < 0) TEST_ERROR;
+
+ /* create and set chunk plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ( H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR;
+ if ( H5Pset_deflate(pid, 9) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL, tid, sid, pid)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close compact plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
+
+ /* close the datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid_copy) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(pid);
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid_copy);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_compressed_named_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_compact_vl_vl
+ *
+ * Purpose: Create a compact dataset w/nested VLEN datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, February 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_compact_vl_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid=-1, tid2=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j, k; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ hvl_t *tvl; /* Temporary pointer to VL information */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): compact dataset with nested VLEN datatype");
+
+ /* set initial data values */
+ for(i=0; i<DIM_SIZE_1; i++) {
+ buf[i].p=HDmalloc((i+1)*sizeof(hvl_t));
+ if(buf[i].p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i);
+ return 1;
+ } /* end if */
+ buf[i].len=i+1;
+ for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
+ if(tvl->p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
+ return 1;
+ } /* end if */
+ tvl->len=j+1;
+ for(k=0; k<(j+1); k++)
+ ((unsigned int *)tvl->p)[k]=i*100+j*10+k;
+ } /* end for */
+ } /* end for */
+
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create nested VL datatype */
+ if ( (tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR;
+
+ /* create and set compact plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ( H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL_VL, tid2, sid, pid)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close compact plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_compact_vl_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_contig_vl_vl
+ *
+ * Purpose: Create a compact dataset w/nested VLEN datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, February 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_contig_vl_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid=-1, tid2=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j, k; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ hvl_t *tvl; /* Temporary pointer to VL information */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): contigous dataset with nested VLEN datatype");
+
+ /* set initial data values */
+ for(i=0; i<DIM_SIZE_1; i++) {
+ buf[i].p=HDmalloc((i+1)*sizeof(hvl_t));
+ if(buf[i].p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i);
+ return;
+ } /* end if */
+ buf[i].len=i+1;
+ for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
+ if(tvl->p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
+ return;
+ } /* end if */
+ tvl->len=j+1;
+ for(k=0; k<(j+1); k++)
+ ((unsigned int *)tvl->p)[k]=i*100+j*10+k;
+ } /* end for */
+ } /* end for */
+
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create nested VL datatype */
+ if ( (tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR;
+
+ /* create and set compact plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close compact plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_contig_vl_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_chunked_vl_vl
+ *
+ * Purpose: Create a dataset that uses a named variable length datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, March 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_chunked_vl_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid2=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j, k; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ hvl_t *tvl; /* Temporary pointer to VL information */
+ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): chunked dataset with nested VLEN datatype");
+
+ /* set initial data values */
+ for(i=0; i<DIM_SIZE_1; i++) {
+ buf[i].p=HDmalloc((i+1)*sizeof(hvl_t));
+ if(buf[i].p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i);
+ return;
+ } /* end if */
+ buf[i].len=i+1;
+ for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
+ if(tvl->p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
+ return;
+ } /* end if */
+ tvl->len=j+1;
+ for(k=0; k<(j+1); k++)
+ ((unsigned int *)tvl->p)[k]=i*100+j*10+k;
+ } /* end for */
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create nested VL datatype */
+ if ( (tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR;
+
+ /* create and set chunk plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ( H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL_VL, tid2, sid, pid)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close compact plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(pid);
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_chunked_vl_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_compressed_vl_vl
+ *
+ * Purpose: Create a dataset that uses a named variable length datatype
+ * in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Saturday, March 11, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_compressed_vl_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid2=-1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j, k; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ hvl_t *tvl; /* Temporary pointer to VL information */
+ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): compressed dataset with nested VLEN datatype");
+
+ /* set initial data values */
+ for(i=0; i<DIM_SIZE_1; i++) {
+ buf[i].p=HDmalloc((i+1)*sizeof(hvl_t));
+ if(buf[i].p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i);
+ return;
+ } /* end if */
+ buf[i].len=i+1;
+ for(tvl=buf[i].p,j=0; j<(i+1); j++, tvl++) {
+ tvl->p=HDmalloc((j+1)*sizeof(unsigned int));
+ if(tvl->p==NULL) {
+ TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j);
+ return;
+ } /* end if */
+ tvl->len=j+1;
+ for(k=0; k<(j+1); k++)
+ ((unsigned int *)tvl->p)[k]=i*100+j*10+k;
+ } /* end for */
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create nested VL datatype */
+ if ( (tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR;
+
+ /* create and set chunk plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ( H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR;
+ if ( H5Pset_deflate(pid, 9) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL_VL, tid2, sid, pid)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close compact plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(pid);
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_compressed_vl_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_option
+ *
+ * Purpose: Create a group in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * March 11, 2006
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hid_t gid = -1, gid2 = -1; /* Group IDs */
+ hid_t gid_sub=-1, gid_sub_sub=-1; /* Sub-group ID */
+ hid_t pid=-1; /* Property ID */
+ hsize_t dim2d[2];
+ int buf[DIM_SIZE_1][DIM_SIZE_2];
+ int i, j;
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING(test_desciption);
+
+ /* set initial data values */
+ for (i=0; i<DIM_SIZE_1; i++)
+ for (j=0; j<DIM_SIZE_2; j++)
+ buf[i][j] = 10000 + 100*i+j;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* create group at the SRC file */
+ if ( (gid = H5Gcreate(fid_src, NAME_GROUP_TOP, (size_t)0)) < 0) TEST_ERROR;
+
+ /* attach attributes to the group */
+ if ( test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim2d[0]=DIM_SIZE_1;
+ dim2d[1]=DIM_SIZE_2;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR;
+
+ /* add a dataset to the top group */
+ if ( (did = H5Dcreate(gid, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT) ) < 0) TEST_ERROR;
+ if ( H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+ if (H5Dclose(did) < 0) TEST_ERROR;
+
+ /* create a sub-group */
+ if ( (gid_sub = H5Gcreate(fid_src, NAME_GROUP_SUB, (size_t)0)) < 0) TEST_ERROR;
+
+ /* add a dataset to the sub group */
+ if ( (did = H5Dcreate(gid_sub, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT) ) < 0) TEST_ERROR;
+ if ( H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+ if (H5Dclose(did) < 0) TEST_ERROR;
+
+ /* create sub-sub-group */
+ if ( (gid_sub_sub = H5Gcreate(gid_sub, NAME_GROUP_SUB_SUB2, (size_t)0)) < 0) TEST_ERROR;
+
+ /* add a dataset to the sub sub group */
+ if ( (did = H5Dcreate(gid_sub_sub, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT) ) < 0) TEST_ERROR;
+ if ( H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+ if (H5Dclose(did) < 0) TEST_ERROR;
+
+ if( H5Gclose(gid_sub_sub) < 0) TEST_ERROR;
+
+ if( H5Gclose(gid_sub) < 0) TEST_ERROR;
+
+ /* close the group */
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination
+ files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* create property to pass copy options */
+ if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR;
+
+ /* set property for shallow copy */
+ if ( H5Pset_copy_object(pid, flag) < 0) TEST_ERROR;
+
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid) < 0) TEST_ERROR;
+
+ /* open the group for copy */
+ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
+
+ /* open the destination group */
+ if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
+
+ /* Check if the groups are equal */
+ if ( compare_groups(gid, gid2) != TRUE) TEST_ERROR;
+
+ /* close the destination group */
+ if ( H5Gclose(gid2) < 0) TEST_ERROR;
+
+ /* close the source group */
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ /* close property */
+ if (H5Pclose(pid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(pid);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Gclose(gid_sub);
+ H5Gclose(gid2);
+ H5Gclose(gid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_option */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test H5Gcopy()
@@ -4908,7 +6269,14 @@ main(void)
nerrors += test_copy_dataset_compact_vl(fapl);
nerrors += test_copy_dataset_compressed_vl(fapl);
nerrors += test_copy_attribute_vl(fapl);
-/* TODO: Add more tests for copying vlen data */
+ nerrors += test_copy_dataset_compact_named_vl(fapl);
+ nerrors += test_copy_dataset_contig_named_vl(fapl);
+ nerrors += test_copy_dataset_chunked_named_vl(fapl);
+ nerrors += test_copy_dataset_compressed_named_vl(fapl);
+ nerrors += test_copy_dataset_compact_vl_vl(fapl);
+ nerrors += test_copy_dataset_contig_vl_vl(fapl);
+ nerrors += test_copy_dataset_chunked_vl_vl(fapl);
+ nerrors += test_copy_dataset_compressed_vl_vl(fapl);
nerrors += test_copy_group_empty(fapl);
nerrors += test_copy_group(fapl);
nerrors += test_copy_group_deep(fapl);
@@ -4919,9 +6287,14 @@ main(void)
nerrors += test_copy_exist(fapl);
nerrors += test_copy_path(fapl);
nerrors += test_copy_same_file_named_datatype(fapl);
+ nerrors += test_copy_option(fapl, H5G_COPY_WITHOUT_ATTR_FLAG, "H5Gcopy: copy without attributes");
+
/* TODO: Add more tests for copying objects in same file */
- nerrors += test_copy_mount(fapl); /* TODO */
-/* TODO: Add more tests for copying objects in mounted files */
+
+
+/* TODO: Add more tests for copying objects in mounted files
+ nerrors += test_copy_mount(fapl);
+*/
/* Reset file address checking info */
addr_reset();