Re: writing attributes to a fileid?

Hi Ed,

You have to open the root group and then attach an attribute. We will check the documentation and fix it.


At 03:57 PM 7/25/2005, Ed Hartnett wrote:
HDF guys,

Can I write an attribute to a fileid, instead of group id? It seems
not, though the documentation implies that I can.

For example this code doesn't work:

   /* See if we can write an attribute to a fileid. */
   if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
                           H5P_DEFAULT)) < 0) ERR;

   /* Attach a text attribute with some of Hamlet's lines. */
   if ((spaceid = H5Screate(H5S_SCALAR)) < 0) ERR;
   if ((typeid = H5Tcopy(H5T_C_S1)) < 0) ERR;
   if (H5Tset_size(typeid, strlen(txt)) < 0) ERR;
   if ((attid = H5Acreate(fileid, ATT1_NAME, typeid, spaceid,
                          H5P_DEFAULT)) < 0) ERR;
   if (H5Awrite(attid, typeid, txt) < 0) ERR;
   if (H5Aclose(attid) < 0 ||
       H5Sclose(spaceid) < 0 ||
       H5Tclose(typeid) < 0 ||
       H5Fclose(fileid) < 0) ERR;

It fails on the H5Acreate, saying that the fileid is not an
appropriate place to define an att.

Is this intended behavior?



Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

Elena Pourmal, HDF QA, Maintenance and Support Team Leader
NCSA University of Illinois at Urbana-Champaign
605 E. Springfield Ave.
Champaign, IL 61820

(217)333-0238 (office)
(217)244-1987 (fax)