diff options
Diffstat (limited to 'src/H5Gdeprec.c')
-rw-r--r-- | src/H5Gdeprec.c | 157 |
1 files changed, 134 insertions, 23 deletions
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 63e5a23..16e8c05 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -234,7 +234,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) /* Create the group through the VOL */ if(NULL == (grp = H5VL_group_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, tmp_gcpl, - H5P_GROUP_ACCESS_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL))) + H5P_GROUP_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") /* Get an atom for the group */ @@ -246,7 +246,7 @@ done: if(H5I_dec_ref(tmp_gcpl) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list") if (ret_value < 0 && grp) - if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -294,7 +294,7 @@ H5Gopen1(hid_t loc_id, const char *name) /* Create the group through the VOL */ if(NULL == (grp = H5VL_group_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, H5P_DEFAULT, - H5AC_ind_dxpl_id, H5_REQUEST_NULL))) + H5AC_ind_read_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") /* Get an atom for the group */ @@ -303,7 +303,7 @@ H5Gopen1(hid_t loc_id, const char *name) done: if (ret_value < 0 && grp) - if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL) < 0) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gopen1() */ @@ -363,7 +363,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new /* Create the link through the VOL */ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, NULL, loc_params2, obj->vol_info->vol_cls, - lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + lcpl_id, H5P_DEFAULT, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if(type == H5L_TYPE_SOFT) { @@ -385,7 +385,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new /* Create the link through the VOL */ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, obj->vol_obj, loc_params, obj->vol_info->vol_cls, - lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + lcpl_id, H5P_DEFAULT, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else if */ else @@ -455,7 +455,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, /* Create the link through the VOL */ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, obj2->vol_obj, loc_params2, obj2->vol_info->vol_cls, - lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + lcpl_id, H5P_DEFAULT, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if(type == H5L_TYPE_SOFT) { @@ -482,7 +482,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, /* Create the link through the VOL */ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, obj->vol_obj, loc_params, obj->vol_info->vol_cls, - lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + lcpl_id, H5P_DEFAULT, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else if */ else @@ -494,6 +494,60 @@ done: /*------------------------------------------------------------------------- + * Function: H5G_link_hard + * + * Purpose: Creates a hard link from NEW_NAME to CUR_NAME. + * + * CUR_NAME must name an existing object. CUR_NAME and + * NEW_NAME are interpreted relative to CUR_LOC_ID and + * NEW_LOC_ID, which are either file IDs or group IDs. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G_link_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, + const char *new_name) +{ + H5G_loc_t cur_loc, *cur_loc_p; /* Information about current link's group */ + H5G_loc_t new_loc, *new_loc_p; /* Information about new link's group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Finish checking arguments */ + if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") + if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + new_loc_p = &new_loc; + if(cur_loc_id == H5L_SAME_LOC) + cur_loc_p = new_loc_p; + else if(new_loc_id == H5L_SAME_LOC) + new_loc_p = cur_loc_p; + else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + + /* Create the link */ + if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, + H5P_DEFAULT, H5P_DEFAULT, H5AC_ind_read_dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_link_hard() */ + + +/*------------------------------------------------------------------------- * Function: H5Gmove * * Purpose: Moves and renames a link. The new API to do this is H5Lmove. @@ -526,7 +580,7 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) /* Create the link through the VOL */ if((ret_value = H5VL_link_move(obj->vol_obj, loc_params1, NULL, loc_params2, obj->vol_info->vol_cls, - H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + H5P_DEFAULT, H5P_DEFAULT, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -578,8 +632,8 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Move the link through the VOL */ if((ret_value = H5VL_link_move(obj1->vol_obj, loc_params1, obj2->vol_obj, loc_params2, - obj1->vol_info->vol_cls, - H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + obj1->vol_info->vol_cls, H5P_DEFAULT, H5P_DEFAULT, + H5AC_ind_read_dxpl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -588,6 +642,63 @@ done: /*------------------------------------------------------------------------- + * Function: H5G_move + * + * Purpose: Renames an object within an HDF5 file and moves it to a new + * group. The original name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, + const char *dst_name) +{ + H5G_loc_t src_loc, *src_loc_p; /* Group info for source location */ + H5G_loc_t dst_loc, *dst_loc_p; /* Group info for destination location */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments */ + if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") + if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!src_name || !*src_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") + if(!dst_name || !*dst_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(src_loc_id == H5L_SAME_LOC) + src_loc_p = dst_loc_p; + else if(dst_loc_id == H5L_SAME_LOC) + dst_loc_p = src_loc_p; + + /* Move the link */ + if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, H5P_DEFAULT, + H5P_DEFAULT, H5AC_ind_read_dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_move() */ + + +/*------------------------------------------------------------------------- * Function: H5Gunlink * * Purpose: Removes a link. The new API is H5Ldelete/H5Ldelete_by_idx. @@ -618,7 +729,7 @@ H5Gunlink(hid_t loc_id, const char *name) /* Delete the link through the VOL */ if(H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_DELETE, - H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + H5AC_ind_read_dxpl_id, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -659,7 +770,7 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) /* Get the link info through the VOL */ if((ret_value = H5VL_link_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_GET_VAL, - H5AC_ind_dxpl_id, H5_REQUEST_NULL, buf, size)) < 0) + H5AC_ind_read_dxpl_id, H5_REQUEST_NULL, buf, size)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value") done: @@ -698,7 +809,7 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(H5G_loc_set_comment(&loc, name, comment, H5P_DEFAULT, H5AC_dxpl_id) < 0) + if(H5G_loc_set_comment(&loc, name, comment, H5P_DEFAULT, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value") done: @@ -745,7 +856,7 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) if(bufsize > 0 && !buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified") - if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value") done: @@ -812,7 +923,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, lnk_op.op_func.op_old = op; /* Call private function. */ - if((ret_value = H5G_iterate(&loc, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_iterate(&loc, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") /* Set the index we stopped at */ @@ -854,7 +965,7 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") @@ -862,7 +973,7 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") /* Retrieve information about the group */ - if(H5G__obj_info(loc.oloc, &grp_info, H5AC_ind_dxpl_id) < 0) + if(H5G__obj_info(loc.oloc, &grp_info, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine") /* Set the number of objects [sic: links] in the group */ @@ -907,7 +1018,7 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Get info */ - if(H5G_get_objinfo(&loc, name, follow_link, statbuf, H5AC_ind_dxpl_id) < 0) + if(H5G_get_objinfo(&loc, name, follow_link, statbuf, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "cannot stat object") done: @@ -1100,14 +1211,14 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a group") /* Call internal function */ if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, - idx, name, size, H5AC_ind_dxpl_id)) < 0) + idx, name, size, H5AC_ind_read_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "can't get object name") done: @@ -1143,13 +1254,13 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "not a group") /* Call internal function*/ - if((ret_value = H5G_obj_get_type_by_idx(loc.oloc, idx, H5AC_ind_dxpl_id)) == H5G_UNKNOWN) + if((ret_value = H5G_obj_get_type_by_idx(loc.oloc, idx, H5AC_ind_read_dxpl_id)) == H5G_UNKNOWN) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object type") done: |