summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c++/src/H5Object.cpp6
-rw-r--r--src/H5Adeprec.c12
-rw-r--r--src/H5Apublic.h2
-rw-r--r--src/H5vers.txt1
-rw-r--r--src/H5version.h15
-rw-r--r--test/tattr.c40
6 files changed, 49 insertions, 27 deletions
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index 2c711e3..894cfef 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -277,11 +277,9 @@ void H5Object::removeAttr( const H5std_string& name ) const
//--------------------------------------------------------------------------
void H5Object::renameAttr(const char* oldname, const char* newname) const
{
- herr_t ret_value = H5Arename(id, oldname, newname);
+ herr_t ret_value = H5Arename2(id, ".", oldname, newname, H5P_DEFAULT);
if (ret_value < 0)
- {
- throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed");
- }
+ throw AttributeIException(inMemFunc("renameAttr"), "H5Arename2 failed");
}
//--------------------------------------------------------------------------
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c
index 6c4502e..75f5191 100644
--- a/src/H5Adeprec.c
+++ b/src/H5Adeprec.c
@@ -334,12 +334,15 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Aget_num_attrs() */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
- * Function: H5Arename
+ * Function: H5Arename1
*
* Purpose: Rename an attribute
*
+ * Note: Deprecated in favor of H5Arename2
+ *
* Return: Success: Non-negative
* Failure: Negative
*
@@ -349,12 +352,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Arename(hid_t loc_id, const char *old_name, const char *new_name)
+H5Arename1(hid_t loc_id, const char *old_name, const char *new_name)
{
H5G_loc_t loc; /* Object location */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Arename, FAIL)
+ FUNC_ENTER_API(H5Arename1, FAIL)
H5TRACE3("e", "i*s*s", loc_id, old_name, new_name);
/* check arguments */
@@ -373,7 +376,8 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name)
done:
FUNC_LEAVE_API(ret_value)
-} /* H5Arename() */
+} /* H5Arename1() */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*--------------------------------------------------------------------------
diff --git a/src/H5Apublic.h b/src/H5Apublic.h
index e1106f9..f154261 100644
--- a/src/H5Apublic.h
+++ b/src/H5Apublic.h
@@ -89,7 +89,6 @@ H5_DLL hid_t H5Acreate(hid_t loc_id, const char *name, hid_t type_id,
H5_DLL hid_t H5Aopen_name(hid_t loc_id, const char *name);
H5_DLL hid_t H5Aopen_idx(hid_t loc_id, unsigned idx);
H5_DLL int H5Aget_num_attrs(hid_t loc_id);
-H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name);
H5_DLL herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op,
void *op_data);
@@ -107,6 +106,7 @@ H5_DLL herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op,
/* Function prototypes */
H5_DLL herr_t H5Adelete1(hid_t loc_id, const char *name);
+H5_DLL herr_t H5Arename1(hid_t loc_id, const char *old_name, const char *new_name);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/src/H5vers.txt b/src/H5vers.txt
index 3bafc28..17dde82 100644
--- a/src/H5vers.txt
+++ b/src/H5vers.txt
@@ -46,6 +46,7 @@
# (although not required, it's easier to compare this file with the headers
# generated if the list below is in alphanumeric sort order - QAK)
FUNCTION: H5Adelete; ; v10, v18
+FUNCTION: H5Arename; ; v16, v18
FUNCTION: H5Eclear; ; v10, v18
FUNCTION: H5Eget_auto; ; v10, v18
FUNCTION: H5Eprint; ; v10, v18
diff --git a/src/H5version.h b/src/H5version.h
index bdfa8bb..a6c8414 100644
--- a/src/H5version.h
+++ b/src/H5version.h
@@ -42,6 +42,10 @@
#define H5Adelete_vers 1
#endif /* !defined(H5Adelete_vers) */
+#if !defined(H5Arename_vers)
+#define H5Arename_vers 1
+#endif /* !defined(H5Arename_vers) */
+
#if !defined(H5Eclear_vers)
#define H5Eclear_vers 1
#endif /* !defined(H5Eclear_vers) */
@@ -118,6 +122,17 @@
#error "H5Adelete_vers set to invalid value"
#endif /* H5Adelete_vers */
+#if !defined(H5Arename_vers) || H5Arename_vers == 2
+#ifndef H5Arename_vers
+#define H5Arename_vers 2
+#endif /* H5Arename_vers */
+#define H5Arename H5Arename2
+#elif H5Arename_vers == 1
+#define H5Arename H5Arename1
+#else /* H5Arename_vers */
+#error "H5Arename_vers set to invalid value"
+#endif /* H5Arename_vers */
+
#if !defined(H5Eclear_vers) || H5Eclear_vers == 2
#ifndef H5Eclear_vers
#define H5Eclear_vers 2
diff --git a/test/tattr.c b/test/tattr.c
index 2c57d49..8a07cae 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -236,51 +236,51 @@ test_attr_basic_write(hid_t fapl)
CHECK(ret, FAIL, "H5Awrite");
/* Check storage size for attribute */
- attr_size=H5Aget_storage_size(attr);
- VERIFY(attr_size, (ATTR1_DIM1*sizeof(int)), "H5A_get_storage_size");
+ attr_size = H5Aget_storage_size(attr);
+ VERIFY(attr_size, (ATTR1_DIM1 * sizeof(int)), "H5A_get_storage_size");
/* Read attribute information immediately, without closing attribute */
- ret=H5Aread(attr,H5T_NATIVE_INT,read_data1);
+ ret = H5Aread(attr, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
+ for(i = 0; i < ATTR1_DIM1; i++)
+ if(attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
/* Close attribute */
- ret=H5Aclose(attr);
+ ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
/* Close attribute */
- ret=H5Aclose(attr2);
+ ret = H5Aclose(attr2);
CHECK(ret, FAIL, "H5Aclose");
/* change attribute name */
- ret=H5Arename(dataset, ATTR1_NAME, ATTR_TMP_NAME);
- CHECK(ret, FAIL, "H5Arename");
+ ret = H5Arename2(dataset, ".", ATTR1_NAME, ATTR_TMP_NAME, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Arename2");
/* Open attribute again */
- attr=H5Aopen_name(dataset, ATTR_TMP_NAME);
+ attr = H5Aopen_name(dataset, ATTR_TMP_NAME);
CHECK(attr, FAIL, "H5Aopen_name");
/* Verify new attribute name */
attr_name_size = H5Aget_name(attr, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");
- if(attr_name_size>0)
- attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char));
+ if(attr_name_size > 0)
+ attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char));
- ret=(herr_t)H5Aget_name(attr, (size_t)(attr_name_size+1), attr_name);
+ ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name);
CHECK(ret, FAIL, "H5Aget_name");
- ret=HDstrcmp(attr_name, ATTR_TMP_NAME);
+ ret = HDstrcmp(attr_name, ATTR_TMP_NAME);
VERIFY(ret, 0, "HDstrcmp");
if(attr_name)
HDfree(attr_name);
/* Read attribute information immediately, without closing attribute */
- ret=H5Aread(attr,H5T_NATIVE_INT,read_data1);
+ ret = H5Aread(attr, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
@@ -3273,7 +3273,7 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
- /* Re-open the file and delete the attribute */
+ /* Re-open the file and operate on the attribute */
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
@@ -3284,8 +3284,12 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen");
+ /* Rename attribute */
+ ret = H5Arename1(dataset, "attr", "attr2");
+ CHECK(ret, FAIL, "H5Arename1");
+
/* Delete attribute */
- ret = H5Adelete1(dataset, "attr");
+ ret = H5Adelete1(dataset, "attr2");
CHECK(ret, FAIL, "H5Adelete1");