summaryrefslogtreecommitdiffstats
path: root/src/H5Adeprec.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2012-04-08 22:22:37 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2012-04-08 22:22:37 (GMT)
commit7d7842302b1dcf0da0067b30c49da59b8f766cb3 (patch)
tree5fd9f29e738290f07ec405d0890eb7a629067083 /src/H5Adeprec.c
parentb56de62ae06434c5966fc07664c44d91b407c515 (diff)
downloadhdf5-7d7842302b1dcf0da0067b30c49da59b8f766cb3.zip
hdf5-7d7842302b1dcf0da0067b30c49da59b8f766cb3.tar.gz
hdf5-7d7842302b1dcf0da0067b30c49da59b8f766cb3.tar.bz2
[svn-r22258] links and attributes VOL routines
change native location token to be of type H5O_loc_t several bug fixes and issues resolved
Diffstat (limited to 'src/H5Adeprec.c')
-rw-r--r--src/H5Adeprec.c79
1 files changed, 30 insertions, 49 deletions
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c
index 806b721..96c03e8 100644
--- a/src/H5Adeprec.c
+++ b/src/H5Adeprec.c
@@ -139,31 +139,38 @@ hid_t
H5Acreate1(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 */
+ void *location = NULL;
+ H5P_genplist_t *plist; /* Property list pointer */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, plist_id);
/* check arguments */
- if(H5I_ATTR == H5I_get_type(loc_id))
+ if(H5I_ATTR_PUBLIC == 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")
+ /* Get correct property list */
+ if(H5P_DEFAULT == plist_id)
+ plist_id = H5P_ATTRIBUTE_CREATE_DEFAULT;
+
+ /* Get the plist structure */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* set creation properties */
+ if(H5P_set(plist, H5A_CRT_TYPE_ID_NAME, &type_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id")
+ if(H5P_set(plist, H5A_CRT_SPACE_ID_NAME, &space_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id")
+ if(H5P_set(plist, H5A_CRT_LOCATION_NAME, &location) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location")
+
+ /* Create the attribute through the VOL */
+ if((ret_value = H5VL_attr_create(loc_id, name, plist_id, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute")
done:
FUNC_LEAVE_API(ret_value)
@@ -195,35 +202,22 @@ done:
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(FAIL)
H5TRACE2("i", "i*s", loc_id, name);
/* check arguments */
- if(H5I_ATTR == H5I_get_type(loc_id))
+ if(H5I_ATTR_PUBLIC == 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: '%s'", name)
-
- /* Register the attribute and get an ID for it */
- if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
+ /* Open the attribute through the VOL */
+ if((ret_value = H5VL_attr_open(loc_id, NULL, name, H5P_DEFAULT)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open attribute")
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() */
@@ -253,33 +247,20 @@ done:
hid_t
H5Aopen_idx(hid_t loc_id, unsigned idx)
{
- H5G_loc_t loc; /* Object location */
- H5A_t *attr = NULL; /* Attribute opened */
hid_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE2("i", "iIu", loc_id, idx);
/* check arguments */
- if(H5I_ATTR == H5I_get_type(loc_id))
+ if(H5I_ATTR_PUBLIC == 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")
- /* Open the attribute in the object header */
- if(NULL == (attr = H5A_open_by_idx(&loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute")
-
- /* Register the attribute and get an ID for it */
- if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
+ if(H5VL_attr_generic(loc_id, H5VL_ATTR_OPEN_BY_IDX, &ret_value, ".", H5_INDEX_CRT_ORDER,
+ H5_ITER_INC, (hsize_t)idx, H5P_DEFAULT, H5P_LINK_ACCESS_DEFAULT) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataset access properties")
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_idx() */