mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-25 17:00:45 +08:00
[svn-r13274] Description:
Relax restriction on the "location ID" for attribute operations to allow file IDs to be used as the location ID. If a file ID is used, the attribute operations will occur on the file's root group. Tested on: FreeBSD/32 6.2 (duty)
This commit is contained in:
parent
487d82bf58
commit
140c0c9db2
@ -172,6 +172,10 @@ New Features
|
||||
|
||||
Library:
|
||||
--------
|
||||
- Relaxed restrictions on attribute operations to allow a file ID to
|
||||
be used as the "location ID". If a file ID is used, the attribute
|
||||
operation will occur on the root group of the file.
|
||||
- QAK - 2007/02/09
|
||||
- Enabled the CORE driver to read an existing file depending on
|
||||
the setting of the backing_store for H5Pset_fapl_core and file
|
||||
open flags. - SLU - 2006/11/30
|
||||
|
16
src/H5A.c
16
src/H5A.c
@ -239,7 +239,7 @@ H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
|
||||
H5TRACE5("i", "isiii", loc_id, name, type_id, space_id, plist_id);
|
||||
|
||||
/* check arguments */
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
@ -447,7 +447,7 @@ H5Aopen_name(hid_t loc_id, const char *name)
|
||||
H5TRACE2("i", "is", loc_id, name);
|
||||
|
||||
/* check arguments */
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
@ -502,7 +502,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx)
|
||||
H5TRACE2("i", "iIu", loc_id, idx);
|
||||
|
||||
/* check arguments */
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
@ -1296,7 +1296,7 @@ H5Aget_info(hid_t loc_id, const char *name, H5A_info_t *ainfo)
|
||||
FUNC_ENTER_API(H5Aget_info, FAIL)
|
||||
|
||||
/* Check args */
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
@ -1347,7 +1347,7 @@ H5Aget_info_by_idx(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order,
|
||||
FUNC_ENTER_API(H5Aget_info_by_idx, FAIL)
|
||||
|
||||
/* Check args */
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
@ -1438,7 +1438,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name)
|
||||
/* check arguments */
|
||||
if(!old_name || !new_name)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "name is nil")
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
@ -1501,7 +1501,7 @@ H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data)
|
||||
H5TRACE4("e", "i*Iuxx", loc_id, attr_num, op, op_data);
|
||||
|
||||
/* check arguments */
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
@ -1549,7 +1549,7 @@ H5Adelete(hid_t loc_id, const char *name)
|
||||
H5TRACE2("e", "is", loc_id, name);
|
||||
|
||||
/* check arguments */
|
||||
if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id))
|
||||
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")
|
||||
|
31
test/tattr.c
31
test/tattr.c
@ -164,9 +164,31 @@ test_attr_basic_write(hid_t fapl)
|
||||
sid2 = H5Screate_simple(ATTR1_RANK, dims2, NULL);
|
||||
CHECK(sid2, FAIL, "H5Screate_simple");
|
||||
|
||||
/* Try to create an attribute on the file (should fail) */
|
||||
ret=H5Acreate(fid1,ATTR1_NAME,H5T_NATIVE_INT,sid2,H5P_DEFAULT);
|
||||
VERIFY(ret, FAIL, "H5Acreate");
|
||||
|
||||
/* Try to create an attribute on the file (should create an attribute on root group) */
|
||||
attr = H5Acreate(fid1, ATTR1_NAME, H5T_NATIVE_INT, sid2, H5P_DEFAULT);
|
||||
CHECK(attr, FAIL, "H5Acreate");
|
||||
|
||||
/* Close attribute */
|
||||
ret = H5Aclose(attr);
|
||||
CHECK(ret, FAIL, "H5Aclose");
|
||||
|
||||
/* Open the root group */
|
||||
group = H5Gopen(fid1, "/");
|
||||
CHECK(group, FAIL, "H5Gopen");
|
||||
|
||||
/* Open attribute again */
|
||||
attr = H5Aopen_name(group, ATTR1_NAME);
|
||||
CHECK(attr, FAIL, "H5Aopen_name");
|
||||
|
||||
/* Close attribute */
|
||||
ret = H5Aclose(attr);
|
||||
CHECK(ret, FAIL, "H5Aclose");
|
||||
|
||||
/* Close root group */
|
||||
ret = H5Gclose(group);
|
||||
CHECK(ret, FAIL, "H5Gclose");
|
||||
|
||||
|
||||
/* Create an attribute for the dataset */
|
||||
attr=H5Acreate(dataset,ATTR1_NAME,H5T_NATIVE_INT,sid2,H5P_DEFAULT);
|
||||
@ -384,7 +406,8 @@ test_attr_basic_read(hid_t fapl)
|
||||
CHECK(ret, FAIL, "H5Dclose");
|
||||
|
||||
/* Open the group */
|
||||
group=H5Gopen(fid1,GROUP1_NAME);
|
||||
group = H5Gopen(fid1,GROUP1_NAME);
|
||||
CHECK(group, FAIL, "H5Gopen");
|
||||
|
||||
/* Verify the correct number of attributes */
|
||||
ret=H5Aget_num_attrs(group);
|
||||
|
Loading…
x
Reference in New Issue
Block a user