summaryrefslogtreecommitdiffstats
path: root/src/H5Aint.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2012-06-11 22:00:40 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2012-06-11 22:00:40 (GMT)
commitf31fac3a23da12287384db7f6aa2937e9461d3fe (patch)
treea24a0a6e33f7289e5c525504e95fdce29599b2d7 /src/H5Aint.c
parent217c553b95358bfb0c41bf54df4f7596055cc9af (diff)
downloadhdf5-f31fac3a23da12287384db7f6aa2937e9461d3fe.zip
hdf5-f31fac3a23da12287384db7f6aa2937e9461d3fe.tar.gz
hdf5-f31fac3a23da12287384db7f6aa2937e9461d3fe.tar.bz2
[svn-r22452] - remove nrefs param
- create a struct to hold parameters for object locations instead of calling into VOL to lookup and free object: * update the implementation for H5Oopen(_by_name/idx/ref) * H5Rderefence * H5Aopen(_by_name), H5Arename(_by_name) * other routines coming later
Diffstat (limited to 'src/H5Aint.c')
-rw-r--r--src/H5Aint.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 74c5590..1bbbd31 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -1259,3 +1259,53 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_dense_post_copy_file_all */
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_rename_by_name
+ *
+ * Purpose: Private version of H5Arename_by_name
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * February 20, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5A_rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name,
+ const char *new_attr_name, hid_t lapl_id)
+{
+ H5G_loc_t obj_loc; /* Location used to open group */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
+ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Avoid thrashing things if the names are the same */
+ if(HDstrcmp(old_attr_name, new_attr_name)) {
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object's location */
+ if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found")
+ loc_found = TRUE;
+
+ /* Call attribute rename routine */
+ if(H5O_attr_rename(obj_loc.oloc, H5AC_dxpl_id, old_attr_name, new_attr_name) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute")
+ } /* end if */
+
+done:
+ /* Release resources */
+ if(loc_found && H5G_loc_free(&obj_loc) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5A_rename_by_name() */