[svn-r12189] Purpose:

New/expanded features

Description:
    Check in Peter's changed for the object copy code:
        - Allow/fix copying datasets using named variable-length datatypes
        - Start adding framework for property list to control how object
            copying occurs.

Platforms tested:
    FreeBSD 4.11 (sleipnir)
    Too minor to require h5committest
This commit is contained in:
Quincey Koziol 2006-04-01 15:14:11 -05:00
parent 1cd1d6956a
commit 4659f50b83
25 changed files with 1965 additions and 249 deletions

View File

@ -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() */

View File

@ -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() */

View File

@ -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() */

192
src/H5G.c
View File

@ -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")
/* 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")
/* Set up opened group location to fill in */
src_loc.oloc = &src_oloc;
src_loc.path = &src_path;
H5G_loc_reset(&src_loc);
if(H5G_copy(&src_loc, &dst_loc, name_dst, plist_id) < 0)
/* 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(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() */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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
}

View File

@ -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:

View File

@ -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 */

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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);
};

View File

@ -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 */

View File

@ -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);

View File

@ -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 */
@ -463,6 +465,52 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5O_shared_copy_file() */
/*-------------------------------------------------------------------------
* 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

View File

@ -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)

View File

@ -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 */

View File

@ -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() */

View File

@ -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

View File

@ -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, " ");

File diff suppressed because it is too large Load Diff