summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5A.c163
-rw-r--r--src/H5Adeprec.c115
-rw-r--r--src/H5Apkg.h4
-rw-r--r--src/H5Apublic.h13
-rw-r--r--test/tattr.c444
5 files changed, 620 insertions, 119 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 3484d45e..5730353 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -66,11 +66,7 @@ typedef struct H5A_iter_cb1 {
/* Local Prototypes */
/********************/
-static hid_t H5A_create(const H5G_loc_t *loc, const char *name,
- const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id);
static herr_t H5A_open_common(const H5G_loc_t *loc, H5A_t *attr);
-static H5A_t *H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name,
- const char *attr_name, hid_t lapl_id, hid_t dxpl_id);
static herr_t H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id);
static herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id);
static hsize_t H5A_get_storage_size(const H5A_t *attr);
@@ -191,49 +187,50 @@ H5A_term_interface(void)
/*--------------------------------------------------------------------------
NAME
- H5Acreate
+ H5Acreate2
PURPOSE
- Creates a dataset as an attribute of another dataset or group
+ Creates an attribute on an object
USAGE
- hid_t H5Acreate (loc_id, name, type_id, space_id, plist_id)
+ hid_t H5Acreate2(loc_id, obj_name, attr_name, type_id, space_id, acpl_id,
+ aapl_id, lapl_id)
hid_t loc_id; IN: Object (dataset or group) to be attached to
- const char *name; IN: Name of attribute to create
- hid_t type_id; IN: ID of datatype for attribute
- hid_t space_id; IN: ID of dataspace for attribute
- hid_t plist_id; IN: ID of creation property list (currently not used)
+ const char *obj_name; IN: Name of object relative to location
+ const char *attr_name; IN: Name of attribute to locate and open
+ hid_t type_id; IN: ID of datatype for attribute
+ hid_t space_id; IN: ID of dataspace for attribute
+ hid_t acpl_id; IN: ID of creation property list (currently not used)
+ hid_t aapl_id; IN: Attribute access property list
+ hid_t lapl_id; IN: Link access property list
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
This function creates an attribute which is attached to the object
- specified with 'location_id'. The name specified with 'name' for each
- attribute for an object must be unique for that object. The 'type_id'
+ specified with 'loc_id/obj_name'. The name specified with 'attr_name' for
+ each attribute for an object must be unique for that object. The 'type_id'
and 'space_id' are created with the H5T and H5S interfaces respectively.
- Currently only simple dataspaces are allowed for attribute dataspaces.
- The 'plist_id' property list is currently un-used, but will be
- used int the future for optional properties of attributes. The attribute
- ID returned from this function must be released with H5Aclose or resource
- leaks will develop.
- The link created (see H5G API documentation for more information on
- link types) is a hard link, so the attribute may be shared among datasets
- and will not be removed from the file until the reference count for the
- attribute is reduced to zero.
- The location object may be either a group or a dataset, both of
- which may have any sort of attribute.
+ The 'aapl_id' property list is currently unused, but will be used in the
+ future for optional attribute access properties. The attribute ID returned
+ from this function must be released with H5Aclose or resource leaks will
+ develop.
--------------------------------------------------------------------------*/
/* ARGSUSED */
hid_t
-H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
- hid_t plist_id)
+H5Acreate2(hid_t loc_id, const char *obj_name, const char *attr_name,
+ hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t UNUSED aapl_id,
+ hid_t lapl_id)
{
H5G_loc_t loc; /* Object location */
+ 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 */
H5T_t *type; /* Datatype to use for attribute */
H5S_t *space; /* Dataspace to use for attribute */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Acreate, FAIL)
- H5TRACE5("i", "isiii", loc_id, name, type_id, space_id, plist_id);
+ FUNC_ENTER_API(H5Acreate2, FAIL)
/* check arguments */
if(H5I_ATTR == H5I_get_type(loc_id))
@@ -242,20 +239,36 @@ H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR))
HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(!obj_name || !*obj_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name")
+ if(!attr_name || !*attr_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name")
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type")
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+ /* 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;
+
/* Go do the real work for attaching the attribute to the dataset */
- if((ret_value = H5A_create(&loc, name, type, space, plist_id, H5AC_dxpl_id)) < 0)
+ if((ret_value = H5A_create(&obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute")
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_API(ret_value)
-} /* H5Acreate() */
+} /* H5Acreate2() */
/*-------------------------------------------------------------------------
@@ -276,17 +289,9 @@ done:
* Programmer: Quincey Koziol
* April 2, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
- * Added a deep copy of the symbol table entry
- *
- * James Laird, <jlaird@ncsa.uiuc.edu> 9 Nov 2005
- * Added Attribute Creation Property List
- *
*-------------------------------------------------------------------------
*/
-static hid_t
+hid_t
H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
const H5S_t *space, hid_t acpl_id, hid_t dxpl_id)
{
@@ -416,13 +421,16 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5Aopen_name
+ H5Aopen
PURPOSE
Opens an attribute for an object by looking up the attribute name
USAGE
- hid_t H5Aopen_name (loc_id, name)
- hid_t loc_id; IN: Object (dataset or group) to be attached to
- const char *name; IN: Name of attribute to locate and open
+ hid_t H5Aopen(loc_id, obj_name, attr_name, aapl_id, lapl_id)
+ hid_t loc_id; IN: Object that attribute is attached to
+ const char *obj_name; IN: Name of object relative to location
+ const char *attr_name; IN: Name of attribute to locate and open
+ hid_t aapl_id; IN: Attribute access property list
+ hid_t lapl_id; IN: Link access property list
RETURNS
ID of attribute on success, negative on failure
@@ -431,29 +439,34 @@ done:
name specified is used to look up the corresponding attribute for the
object. The attribute ID returned from this function must be released with
H5Aclose or resource leaks will develop.
- The location object may be either a group or a dataset, both of
- which may have any sort of attribute.
--------------------------------------------------------------------------*/
hid_t
-H5Aopen_name(hid_t loc_id, const char *name)
+H5Aopen(hid_t loc_id, const char *obj_name, const char *attr_name,
+ hid_t UNUSED aapl_id, hid_t lapl_id)
{
H5G_loc_t loc; /* Object location */
H5A_t *attr = NULL; /* Attribute opened */
hid_t ret_value;
- FUNC_ENTER_API(H5Aopen_name, FAIL)
- H5TRACE2("i", "is", loc_id, name);
+ FUNC_ENTER_API(H5Aopen, FAIL)
/* check arguments */
if(H5I_ATTR == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(!obj_name || !*obj_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name")
+ if(!attr_name || !*attr_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name")
+ if(H5P_DEFAULT == lapl_id)
+ lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
/* Open the attribute on the object header */
- if(NULL == (attr = H5A_open_by_name(&loc, ".", name, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)))
+ if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, H5AC_ind_dxpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
/* Register the attribute and get an ID for it */
@@ -467,7 +480,7 @@ done:
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
FUNC_LEAVE_API(ret_value)
-} /* H5Aopen_name() */
+} /* H5Aopen() */
/*--------------------------------------------------------------------------
@@ -673,7 +686,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5A_t *
+H5A_t *
H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name,
hid_t lapl_id, hid_t dxpl_id)
{
@@ -1401,14 +1414,48 @@ H5A_get_storage_size(const H5A_t *attr)
*-------------------------------------------------------------------------
*/
herr_t
-H5Aget_info(hid_t loc_id, const char *obj_name, const char *attr_name,
+H5Aget_info(hid_t attr_id, H5A_info_t *ainfo)
+{
+ H5A_t *attr; /* Attribute object for name */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(H5Aget_info, FAIL)
+
+ /* Check args */
+ if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
+
+ /* Get the attribute information */
+ if(H5A_get_info(attr, ainfo) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Aget_info() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Aget_info_by_name
+ *
+ * Purpose: Retrieve information about an attribute by name.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * February 6, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
H5A_info_t *ainfo, hid_t lapl_id)
{
H5G_loc_t loc; /* Object location */
H5A_t *attr = NULL; /* Attribute object for name */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Aget_info, FAIL)
+ FUNC_ENTER_API(H5Aget_info_by_name, FAIL)
/* Check args */
if(H5I_ATTR == H5I_get_type(loc_id))
@@ -1441,7 +1488,7 @@ done:
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
FUNC_LEAVE_API(ret_value)
-} /* end H5Aget_info() */
+} /* end H5Aget_info_by_name() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c
index 9b49b81..b235a5c 100644
--- a/src/H5Adeprec.c
+++ b/src/H5Adeprec.c
@@ -108,6 +108,121 @@ H5A_init_deprec_interface(void)
/*--------------------------------------------------------------------------
NAME
+ H5Acreate
+ PURPOSE
+ Creates an attribute on an object
+ USAGE
+ hid_t H5Acreate (loc_id, name, type_id, space_id, plist_id)
+ hid_t loc_id; IN: Object (dataset or group) to be attached to
+ const char *name; IN: Name of attribute to create
+ hid_t type_id; IN: ID of datatype for attribute
+ hid_t space_id; IN: ID of dataspace for attribute
+ hid_t plist_id; IN: ID of creation property list (currently not used)
+ RETURNS
+ Non-negative on success/Negative on failure
+
+ DESCRIPTION
+ This function creates an attribute which is attached to the object
+ specified with 'location_id'. The name specified with 'name' for each
+ attribute for an object must be unique for that object. The 'type_id'
+ and 'space_id' are created with the H5T and H5S interfaces respectively.
+ The attribute ID returned from this function must be released with H5Aclose
+ or resource leaks will develop.
+
+--------------------------------------------------------------------------*/
+hid_t
+H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
+ hid_t plist_id)
+{
+ H5G_loc_t loc; /* Object location */
+ H5T_t *type; /* Datatype to use for attribute */
+ H5S_t *space; /* Dataspace to use for attribute */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Acreate, FAIL)
+ H5TRACE5("i", "isiii", loc_id, name, type_id, space_id, plist_id);
+
+ /* check arguments */
+ if(H5I_ATTR == H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type")
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+
+ /* Go do the real work for attaching the attribute to the dataset */
+ if((ret_value = H5A_create(&loc, name, type, space, plist_id, H5AC_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Acreate() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Aopen_name
+ PURPOSE
+ Opens an attribute for an object by looking up the attribute name
+ USAGE
+ hid_t H5Aopen_name (loc_id, name)
+ hid_t loc_id; IN: Object (dataset or group) to be attached to
+ const char *name; IN: Name of attribute to locate and open
+ RETURNS
+ ID of attribute on success, negative on failure
+
+ DESCRIPTION
+ This function opens an existing attribute for access. The attribute
+ name specified is used to look up the corresponding attribute for the
+ object. The attribute ID returned from this function must be released with
+ H5Aclose or resource leaks will develop.
+ The location object may be either a group or a dataset, both of
+ which may have any sort of attribute.
+--------------------------------------------------------------------------*/
+hid_t
+H5Aopen_name(hid_t loc_id, const char *name)
+{
+ H5G_loc_t loc; /* Object location */
+ H5A_t *attr = NULL; /* Attribute opened */
+ hid_t ret_value;
+
+ FUNC_ENTER_API(H5Aopen_name, FAIL)
+ H5TRACE2("i", "is", loc_id, name);
+
+ /* check arguments */
+ if(H5I_ATTR == H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+
+ /* Open the attribute on the object header */
+ if(NULL == (attr = H5A_open_by_name(&loc, ".", name, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
+
+ /* Register the attribute and get an ID for it */
+ if((ret_value = H5I_register(H5I_ATTR, attr)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
+
+done:
+ /* Cleanup on failure */
+ if(ret_value < 0)
+ if(attr && H5A_close(attr) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+
+ FUNC_LEAVE_API(ret_value)
+} /* H5Aopen_name() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5Aopen_idx
PURPOSE
Opens the n'th attribute for an object
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index c7d5ba3..59a2032 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -171,6 +171,10 @@ H5_DLLVAR const H5B2_class_t H5A_BT2_CORDER[1];
/* Function prototypes for H5A package scope */
H5_DLL herr_t H5A_init(void);
+H5_DLL hid_t H5A_create(const H5G_loc_t *loc, const char *name,
+ const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id);
+H5_DLL H5A_t * H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name,
+ const char *attr_name, hid_t lapl_id, hid_t dxpl_id);
H5_DLL H5A_t *H5A_open_by_idx(const H5G_loc_t *loc, const char *obj_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id, hid_t dxpl_id);
H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr);
diff --git a/src/H5Apublic.h b/src/H5Apublic.h
index cde9bc6..3a440a9 100644
--- a/src/H5Apublic.h
+++ b/src/H5Apublic.h
@@ -45,9 +45,10 @@ typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/,
const char *attr_name/*in*/, const H5A_info_t *ainfo/*in*/, void *op_data/*in,out*/);
/* Public function prototypes */
-H5_DLL hid_t H5Acreate(hid_t loc_id, const char *name, hid_t type_id,
- hid_t space_id, hid_t plist_id);
-H5_DLL hid_t H5Aopen_name(hid_t loc_id, const char *name);
+H5_DLL hid_t H5Acreate2(hid_t loc_id, const char *obj_name, const char *attr_name,
+ hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id);
+H5_DLL hid_t H5Aopen(hid_t loc_id, const char *obj_name, const char *attr_name,
+ hid_t aapl_id, hid_t lapl_id);
H5_DLL hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t aapl_id,
hid_t lapl_id);
@@ -62,7 +63,8 @@ H5_DLL ssize_t H5Aget_name_by_idx(hid_t loc_id, const char *obj_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
char *name /*out*/, size_t size, hid_t lapl_id);
H5_DLL hsize_t H5Aget_storage_size(hid_t attr_id);
-H5_DLL herr_t H5Aget_info(hid_t loc_id, const char *obj_name,
+H5_DLL herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/);
+H5_DLL herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name,
const char *attr_name, H5A_info_t *ainfo /*out*/, hid_t lapl_id);
H5_DLL herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
@@ -82,6 +84,9 @@ H5_DLL herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name,
*
* Use of these functions and variables is deprecated.
*/
+H5_DLL hid_t H5Acreate(hid_t loc_id, const char *name, hid_t type_id,
+ hid_t space_id, hid_t plist_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);
diff --git a/test/tattr.c b/test/tattr.c
index 26c2597..1cd3a2f 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -2982,12 +2982,12 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
/* Retrieve information for attribute */
sprintf(attrname, "attr %02u", u);
- ret = H5Aget_info(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Aget_info");
+ ret = H5Aget_info_by_name(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
/* Verify creation order of attribute */
- VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info");
- VERIFY(ainfo.corder, u, "H5Aget_info");
+ VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info_by_name");
+ VERIFY(ainfo.corder, u, "H5Aget_info_by_name");
} /* end for */
} /* end for */
@@ -3209,12 +3209,12 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
/* Retrieve information for attribute */
sprintf(attrname, "attr %02u", u);
- ret = H5Aget_info(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Aget_info");
+ ret = H5Aget_info_by_name(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Aget_info_by_name");
/* Verify creation order of attribute */
- VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info");
- VERIFY(ainfo.corder, u, "H5Aget_info");
+ VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info_by_name");
+ VERIFY(ainfo.corder, u, "H5Aget_info_by_name");
} /* end for */
} /* end for */
@@ -4748,7 +4748,7 @@ HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr);
op_data->ncalled++;
/* Get the attribute information directly to compare */
- if(H5Aget_info(loc_id, ".", attr_name, &my_info, H5P_DEFAULT) < 0)
+ if(H5Aget_info_by_name(loc_id, ".", attr_name, &my_info, H5P_DEFAULT) < 0)
return(H5_ITER_ERROR);
/* Check more things for revised attribute iteration (vs. older attribute iteration) */
@@ -4991,6 +4991,7 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
return(-1);
} /* end attr_iterate_check() */
+
/****************************************************************
**
** test_attr_iterate2(): Test basic H5A (attribute) code.
@@ -5258,8 +5259,72 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
+
+ /* Free the "visited link" array */
+ HDfree(visited);
} /* test_attr_iterate2() */
+
+/*-------------------------------------------------------------------------
+ * Function: attr_open_by_idx_check
+ *
+ * Purpose: Check opening attribute by index on an object
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, February 21, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
+ unsigned max_attrs)
+{
+ hid_t attr_id; /* ID of attribute to test */
+ H5A_info_t ainfo; /* Attribute info */
+ int old_nerrs; /* Number of errors when entering this check */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
+
+ /* Retrieve the current # of reported errors */
+ old_nerrs = GetTestNumErrs();
+
+ /* Open each attribute on object by index and check that it's the correct one */
+ for(u = 0; u < max_attrs; u++) {
+ /* Open the attribute */
+ attr_id = H5Aopen_by_idx(obj_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr_id, FAIL, "H5Aopen_by_idx");
+
+ /* Get the attribute's information */
+ ret = H5Aget_info(attr_id, &ainfo);
+ CHECK(ret, FAIL, "H5Aget_info");
+
+ /* Check that the object is the correct one */
+ if(order == H5_ITER_INC) {
+ VERIFY(ainfo.corder, u, "H5Aget_info");
+ } /* end if */
+ else if(order == H5_ITER_DEC) {
+ VERIFY(ainfo.corder, (max_attrs - (u + 1)), "H5Aget_info");
+ } /* end if */
+ else {
+ /* XXX: What to do about native order? */
+ } /* end else */
+
+ /* Close attribute */
+ ret = H5Aclose(attr_id);
+ CHECK(ret, FAIL, "H5Aclose");
+ } /* end for */
+
+ /* Retrieve current # of errors */
+ if(old_nerrs == GetTestNumErrs())
+ return(0);
+ else
+ return(-1);
+} /* end attr_open_by_idx_check() */
+
+
/****************************************************************
**
** test_attr_open_by_idx(): Test basic H5A (attribute) code.
@@ -5284,9 +5349,6 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
hsize_t corder_count; /* # of records in creation order index */
H5_index_t idx_type; /* Type of index to operate on */
H5_iter_order_t order; /* Order within in the index */
- attr_iter_info_t iter_info; /* Iterator info */
- hbool_t *visited = NULL; /* Array of flags for visiting links */
- hsize_t idx; /* Start index for iteration */
hbool_t use_index; /* Use index on creation order values */
char attrname[NAME_BUF_SIZE]; /* Name of attribute */
unsigned curr_dset; /* Current dataset to work on */
@@ -5305,12 +5367,6 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
- /* Allocate the "visited link" array */
- iter_info.max_visit = max_compact * 2;
- visited = HDmalloc(sizeof(hbool_t) * iter_info.max_visit);
- CHECK(visited, NULL, "HDmalloc");
- iter_info.visited = visited;
-
/* Loop over operating on different indices on link fields */
for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
/* Loop over operating in different orders */
@@ -5321,29 +5377,29 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
if(idx_type == H5_INDEX_CRT_ORDER) {
if(order == H5_ITER_INC) {
if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Increasing Order w/Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing Order w/o Creation Order Index\n"))
} /* end if */
else {
if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Decreasing Order w/Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing Order w/o Creation Order Index\n"))
} /* end else */
} /* end if */
else {
if(order == H5_ITER_INC) {
if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order w/Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/o Creation Order Index\n"))
} /* end if */
else {
if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order w/Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/o Creation Order Index\n"))
} /* end else */
} /* end else */
@@ -5388,9 +5444,9 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
is_dense = H5O_is_attr_dense_test(my_dataset);
VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- /* Check for iterating over object with no attributes (should be OK) */
- ret = H5Aiterate2(my_dataset, ".", idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Aiterate2");
+ /* Check for opening an attribute on an object with no attributes */
+ ret = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(ret, FAIL, "H5Aopen_by_idx");
/* Create attributes, up to limit of compact form */
for(u = 0; u < max_compact; u++) {
@@ -5421,14 +5477,13 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
is_dense = H5O_is_attr_dense_test(my_dataset);
VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- /* Check for out of bound iteration */
- idx = u;
- ret = H5Aiterate2(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT);
- VERIFY(ret, FAIL, "H5Aiterate2");
+ /* Check for out of bound opening an attribute on an object */
+ ret = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(ret, FAIL, "H5Aopen_by_idx");
- /* Test iteration over attributes stored compactly */
- ret = attr_iterate_check(my_dataset, idx_type, order, u, &iter_info);
- CHECK(ret, FAIL, "attr_iterate_check");
+ /* Test opening attributes by index stored compactly */
+ ret = attr_open_by_idx_check(my_dataset, idx_type, order, u);
+ CHECK(ret, FAIL, "attr_open_by_idx_check");
} /* end for */
@@ -5495,14 +5550,13 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
} /* end if */
- /* Check for out of bound iteration */
- idx = u;
- ret = H5Aiterate2(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT);
- VERIFY(ret, FAIL, "H5Aiterate2");
+ /* Check for out of bound opening an attribute on an object */
+ ret = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(ret, FAIL, "H5Aopen_by_idx");
- /* Test iteration over attributes stored densely */
- ret = attr_iterate_check(my_dataset, idx_type, order, u, &iter_info);
- CHECK(ret, FAIL, "attr_iterate_check");
+ /* Test opening attributes by index stored compactly */
+ ret = attr_open_by_idx_check(my_dataset, idx_type, order, u);
+ CHECK(ret, FAIL, "attr_open_by_idx_check");
} /* end for */
/* Close Datasets */
@@ -5529,6 +5583,286 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
} /* test_attr_open_by_idx() */
+
+/*-------------------------------------------------------------------------
+ * Function: attr_open_check
+ *
+ * Purpose: Check opening attribute on an object
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, February 21, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+attr_open_check(hid_t obj_id, unsigned max_attrs)
+{
+ hid_t attr_id; /* ID of attribute to test */
+ H5A_info_t ainfo; /* Attribute info */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ int old_nerrs; /* Number of errors when entering this check */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
+
+ /* Retrieve the current # of reported errors */
+ old_nerrs = GetTestNumErrs();
+
+ /* Open each attribute on object by index and check that it's the correct one */
+ for(u = 0; u < max_attrs; u++) {
+ /* Open the attribute */
+ sprintf(attrname, "attr %02u", u);
+ attr_id = H5Aopen(obj_id, ".", attrname, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr_id, FAIL, "H5Aopen");
+
+ /* Get the attribute's information */
+ ret = H5Aget_info(attr_id, &ainfo);
+ CHECK(ret, FAIL, "H5Aget_info");
+
+ /* Check that the object is the correct one */
+ VERIFY(ainfo.corder, u, "H5Aget_info");
+
+ /* Close attribute */
+ ret = H5Aclose(attr_id);
+ CHECK(ret, FAIL, "H5Aclose");
+ } /* end for */
+
+ /* Retrieve current # of errors */
+ if(old_nerrs == GetTestNumErrs())
+ return(0);
+ else
+ return(-1);
+} /* end attr_open_check() */
+
+
+/****************************************************************
+**
+** test_attr_open(): Test basic H5A (attribute) code.
+** Tests opening attributes by name
+**
+****************************************************************/
+static void
+test_attr_open(hbool_t new_format, hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ hbool_t use_index; /* Use index on creation order values */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
+
+ /* Create dataspace for dataset & attributes */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Create dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Query the attribute creation properties */
+ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+
+ /* Loop over using index for creation order value */
+ for(use_index = FALSE; use_index <= TRUE; use_index++) {
+ /* Print appropriate test message */
+ if(use_index)
+ MESSAGE(5, ("Testing Opening Attributes By Name w/Creation Order Index\n"))
+ else
+ MESSAGE(5, ("Testing Opening Attributes By Name w/o Creation Order Index\n"))
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Set attribute creation order tracking & indexing for object */
+ ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
+ CHECK(ret, FAIL, "H5Pset_attr_creation_order");
+
+ /* Create datasets */
+ dset1 = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dset1, FAIL, "H5Dcreate");
+ dset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dset2, FAIL, "H5Dcreate");
+ dset3 = H5Dcreate(fid, DSET3_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dset3, FAIL, "H5Dcreate");
+
+ /* Work on all the datasets */
+ for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch(curr_dset) {
+ case 0:
+ my_dataset = dset1;
+ break;
+
+ case 1:
+ my_dataset = dset2;
+ break;
+
+ case 2:
+ my_dataset = dset3;
+ break;
+
+ default:
+ HDassert(0 && "Too many datasets!");
+ } /* end switch */
+
+ /* Check on dataset's attribute storage status */
+ is_empty = H5O_is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
+ is_dense = H5O_is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+
+ /* Check for opening a non-existant attribute on an object with no attributes */
+ ret = H5Aopen(my_dataset, ".", "foo", H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(ret, FAIL, "H5Aopen");
+
+ /* Create attributes, up to limit of compact form */
+ for(u = 0; u < max_compact; u++) {
+ /* Create attribute */
+ sprintf(attrname, "attr %02u", u);
+ attr = H5Acreate(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
+
+ /* Write data into the attribute */
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Verify information for new attribute */
+ ret = attr_info_by_idx_check(my_dataset, attrname, (hsize_t)u, use_index);
+ CHECK(ret, FAIL, "attr_info_by_idx_check");
+ } /* end for */
+
+ /* Verify state of object */
+ ret = H5O_num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O_num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
+ is_empty = H5O_is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
+ is_dense = H5O_is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+
+ /* Check for opening a non-existant attribute on an object with compact attribute storage */
+ ret = H5Aopen(my_dataset, ".", "foo", H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(ret, FAIL, "H5Aopen");
+
+ /* Test opening attributes stored compactly */
+ ret = attr_open_check(my_dataset, u);
+ CHECK(ret, FAIL, "attr_open_check");
+ } /* end for */
+
+
+ /* Work on all the datasets */
+ for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch(curr_dset) {
+ case 0:
+ my_dataset = dset1;
+ break;
+
+ case 1:
+ my_dataset = dset2;
+ break;
+
+ case 2:
+ my_dataset = dset3;
+ break;
+
+ default:
+ HDassert(0 && "Too many datasets!");
+ } /* end switch */
+
+ /* Create more attributes, to push into dense form */
+ for(u = max_compact; u < (max_compact * 2); u++) {
+ /* Create attribute */
+ sprintf(attrname, "attr %02u", u);
+ attr = H5Acreate(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
+
+ /* Write data into the attribute */
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Verify state of object */
+ if(u >= max_compact) {
+ is_dense = H5O_is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ } /* end if */
+
+ /* Verify information for new attribute */
+ ret = attr_info_by_idx_check(my_dataset, attrname, (hsize_t)u, use_index);
+ CHECK(ret, FAIL, "attr_info_by_idx_check");
+ } /* end for */
+
+ /* Verify state of object */
+ ret = H5O_num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O_num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
+ is_empty = H5O_is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
+ is_dense = H5O_is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+
+ if(new_format) {
+ /* Retrieve & verify # of records in the name & creation order indices */
+ ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O_attr_dense_info_test");
+ if(use_index)
+ VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
+ } /* end if */
+
+ /* Check for opening a non-existant attribute on an object with dense attribute storage */
+ ret = H5Aopen(my_dataset, ".", "foo", H5P_DEFAULT, H5P_DEFAULT);
+ VERIFY(ret, FAIL, "H5Aopen");
+
+ /* Test opening attributes stored compactly */
+ ret = attr_open_check(my_dataset, u);
+ CHECK(ret, FAIL, "attr_open_check");
+ } /* end for */
+
+ /* Close Datasets */
+ ret = H5Dclose(dset1);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Dclose(dset2);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Dclose(dset3);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end for */
+
+ /* Close property list */
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+} /* test_attr_open() */
+
/****************************************************************
**
** test_attr_shared_write(): Test basic H5A (attribute) code.
@@ -5692,8 +6026,8 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
/* Alternate between creating "small" & "big" attributes */
if(u % 2) {
/* Create "small" attribute on first dataset */
- attr = H5Acreate(dataset, attrname, attr_tid, sid, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate");
+ attr = H5Acreate2(dataset, ".", attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
is_shared = H5A_is_shared_test(attr);
@@ -5706,8 +6040,8 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
} /* end if */
else {
/* Create "big" attribute on first dataset */
- attr = H5Acreate(dataset, attrname, attr_tid, big_sid, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate");
+ attr = H5Acreate2(dataset, ".", attrname, attr_tid, big_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
is_shared = H5A_is_shared_test(attr);
@@ -5744,8 +6078,8 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
/* Alternate between creating "small" & "big" attributes */
if(u % 2) {
/* Create "small" attribute on second dataset */
- attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate");
+ attr = H5Acreate2(dataset2, ".", attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
is_shared = H5A_is_shared_test(attr);
@@ -5758,8 +6092,8 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
} /* end if */
else {
/* Create "big" attribute on second dataset */
- attr = H5Acreate(dataset2, attrname, attr_tid, big_sid, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate");
+ attr = H5Acreate2(dataset2, ".", attrname, attr_tid, big_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
is_shared = H5A_is_shared_test(attr);
@@ -7143,11 +7477,8 @@ test_attr(void)
test_attr_info_by_idx(new_format, my_fcpl, my_fapl); /* Test querying attribute info by index */
test_attr_delete_by_idx(new_format, my_fcpl, my_fapl); /* Test deleting attribute by index */
test_attr_iterate2(new_format, my_fcpl, my_fapl); /* Test iterating over attributes by index */
-#ifdef NOT_YET
test_attr_open_by_idx(new_format, my_fcpl, my_fapl); /* Test opening attributes by index */
-#else /* NOT_YET */
-HDfprintf(stderr, "Finish H5Aopen_by_idx() test!\n");
-#endif /* NOT_YET */
+ test_attr_open(new_format, my_fcpl, my_fapl); /* Test opening attributes by name */
/* More complex tests with both "new format" and "shared" attributes */
if(use_shared == TRUE) {
@@ -7163,9 +7494,8 @@ HDfprintf(stderr, "Finish H5Aopen_by_idx() test!\n");
test_attr_info_by_idx(new_format, fcpl, my_fapl); /* Test querying attribute info by index */
test_attr_delete_by_idx(new_format, fcpl, my_fapl); /* Test deleting attribute by index */
test_attr_iterate2(new_format, fcpl, my_fapl); /* Test iterating over attributes by index */
-#ifdef NOT_YET
test_attr_open_by_idx(new_format, fcpl, my_fapl); /* Test opening attributes by index */
-#endif /* NOT_YET */
+ test_attr_open(new_format, fcpl, my_fapl); /* Test opening attributes by name */
} /* end else */
} /* end for */