@@ -2285,81 +2285,6 @@ NXstatus NX5initgroupdir(NXhandle fid) {
2285
2285
return NXstatus::NX_OK;
2286
2286
}
2287
2287
2288
- /* ------------------------------------------------------------------------*/
2289
- NXstatus NX5putattra (NXhandle handle, CONSTCHAR *name, const void *data, const int rank, const int dim[],
2290
- const NXnumtype iType) {
2291
- hid_t datatype1, dataspace;
2292
- hid_t type;
2293
- pNexusFile5 pFile;
2294
- int i;
2295
- hid_t vid, iATT;
2296
- herr_t iRet;
2297
- hsize_t mydim[H5S_MAX_RANK];
2298
-
2299
- pFile = NXI5assert (handle);
2300
-
2301
- for (i = 0 ; i < rank; i++) {
2302
- mydim[i] = static_cast <hsize_t >(dim[i]);
2303
- }
2304
-
2305
- /* determine vid */
2306
- vid = getAttVID (pFile);
2307
- iATT = H5Aopen_by_name (vid, " ." , name, H5P_DEFAULT, H5P_DEFAULT);
2308
- if (iATT > 0 ) {
2309
- H5Aclose (iATT);
2310
- iRet = H5Adelete (vid, name);
2311
- if (iRet < 0 ) {
2312
- NXReportError (" ERROR: old attribute cannot be removed! " );
2313
- killAttVID (pFile, vid);
2314
- return NXstatus::NX_ERROR;
2315
- }
2316
- }
2317
-
2318
- if (rank < 0 ) {
2319
- char pBuffer[256 ];
2320
- sprintf (pBuffer, " ERROR: invalid rank specified %s" , name);
2321
- NXReportError (pBuffer);
2322
- return NXstatus::NX_ERROR;
2323
- }
2324
-
2325
- type = nxToHDF5Type (iType);
2326
-
2327
- datatype1 = H5Tcopy (type);
2328
- if (iType == NXnumtype::CHAR) {
2329
- H5Tset_size (datatype1, static_cast <size_t >(dim[rank - 1 ]));
2330
- dataspace = H5Screate_simple (rank - 1 , mydim, NULL );
2331
- } else {
2332
- dataspace = H5Screate_simple (rank, mydim, NULL );
2333
- }
2334
-
2335
- iATT = H5Acreate (vid, static_cast <const char *>(name), datatype1, dataspace, H5P_DEFAULT, H5P_DEFAULT);
2336
-
2337
- if (iATT < 0 ) {
2338
- NXReportError (" ERROR: creating attribute failed" );
2339
- return NXstatus::NX_ERROR;
2340
- } else {
2341
- pFile->iCurrentA = iATT;
2342
- }
2343
-
2344
- iRet = H5Awrite (pFile->iCurrentA , datatype1, data);
2345
- if (iRet < 0 ) {
2346
- NXReportError (" ERROR: failure to write attribute" );
2347
- return NXstatus::NX_ERROR;
2348
- }
2349
-
2350
- // less than zero is an error so just accumulate them
2351
- iRet += H5Sclose (dataspace);
2352
- iRet += H5Tclose (datatype1);
2353
- iRet += H5Aclose (pFile->iCurrentA );
2354
- pFile->iCurrentA = 0 ;
2355
- if (iRet < 0 ) {
2356
- NXReportError (" ERROR: HDF cannot close attribute" );
2357
- return NXstatus::NX_ERROR;
2358
- }
2359
-
2360
- return NXstatus::NX_OK;
2361
- }
2362
-
2363
2288
/* ------------------------------------------------------------------------*/
2364
2289
NXstatus NX5getnextattra (NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType) {
2365
2290
pNexusFile5 pFile;
@@ -2418,95 +2343,6 @@ NXstatus NX5getnextattra(NXhandle handle, NXname pName, int *rank, int dim[], NX
2418
2343
return NX5getattrainfo (handle, pName, rank, dim, iType);
2419
2344
}
2420
2345
/* ------------------------------------------------------------------------*/
2421
- NXstatus NX5getattra (NXhandle handle, const char *name, void *data) {
2422
- pNexusFile5 pFile;
2423
- int iStart[H5S_MAX_RANK], status;
2424
- hid_t vid;
2425
- hid_t memtype_id, filespace, datatype;
2426
- H5T_class_t tclass;
2427
- hsize_t dims[H5S_MAX_RANK];
2428
- htri_t is_vlen_str = 0 ; /* false */
2429
- char **vstrdata = NULL ;
2430
-
2431
- pFile = NXI5assert (handle);
2432
-
2433
- vid = getAttVID (pFile);
2434
- pFile->iCurrentA = H5Aopen_by_name (vid, " ." , name, H5P_DEFAULT, H5P_DEFAULT);
2435
- if (pFile->iCurrentA < 0 ) {
2436
- pFile->iCurrentA = 0 ;
2437
- NXReportError (" ERROR: unable to open attribute" );
2438
- return NXstatus::NX_ERROR;
2439
- }
2440
- filespace = H5Aget_space (pFile->iCurrentA );
2441
- datatype = H5Aget_type (pFile->iCurrentA );
2442
- auto ndims = H5Sget_simple_extent_dims (filespace, dims, NULL );
2443
-
2444
- is_vlen_str = H5Tis_variable_str (datatype);
2445
- if (ndims == 0 && is_vlen_str) {
2446
- /* this assumes a fixed size - is this dangerous? */
2447
- char *strdata = static_cast <char *>(calloc (512 , sizeof (char )));
2448
- status = H5Aread (pFile->iCurrentA , H5S_ALL, &strdata);
2449
- if (status >= 0 ) {
2450
- #if defined(__GNUC__) && !(defined(__clang__))
2451
- #pragma GCC diagnostic push
2452
- #pragma GCC diagnostic ignored "-Wstringop-truncation"
2453
- #endif
2454
- std::strncpy (static_cast <char *>(data), strdata, strlen (strdata));
2455
- #if defined(__GNUC__) && !(defined(__clang__))
2456
- #pragma GCC diagnostic pop
2457
- #endif
2458
- }
2459
- free (strdata);
2460
-
2461
- H5Sclose (filespace);
2462
- H5Tclose (datatype);
2463
- if (status < 0 )
2464
- return NXstatus::NX_ERROR;
2465
- return NXstatus::NX_OK;
2466
- }
2467
- tclass = H5Tget_class (datatype);
2468
- /* stop gap kludge for fixed length strings */
2469
- if (tclass == H5T_STRING && !is_vlen_str) {
2470
- char *datatmp = NULL ;
2471
- status = readStringAttribute (pFile->iCurrentA , &datatmp);
2472
- if (status < 0 )
2473
- return NXstatus::NX_ERROR;
2474
- strcpy (static_cast <char *>(data), datatmp);
2475
- free (datatmp);
2476
- return NXstatus::NX_OK;
2477
- }
2478
-
2479
- memset (iStart, 0 , H5S_MAX_RANK * sizeof (int ));
2480
- /* map datatypes of other plateforms */
2481
- if (is_vlen_str) {
2482
- vstrdata = static_cast <char **>(malloc ((size_t )dims[0 ] * sizeof (char *)));
2483
- memtype_id = H5Tcopy (H5T_C_S1);
2484
- H5Tset_size (memtype_id, H5T_VARIABLE);
2485
- status = H5Aread (pFile->iCurrentA , memtype_id, vstrdata);
2486
- (static_cast <char *>(data))[0 ] = ' \0 ' ;
2487
- if (status >= 0 ) {
2488
- for (hsize_t i = 0 ; i < dims[0 ]; ++i) {
2489
- if (vstrdata[i] != NULL ) {
2490
- strcat (static_cast <char *>(data), vstrdata[i]);
2491
- }
2492
- }
2493
- }
2494
- H5Dvlen_reclaim (memtype_id, pFile->iCurrentS , H5P_DEFAULT, vstrdata);
2495
- free (vstrdata);
2496
- H5Tclose (memtype_id);
2497
- } else if (tclass == H5T_STRING) {
2498
- status = H5Aread (pFile->iCurrentA , datatype, data);
2499
- } else {
2500
- memtype_id = h5MemType (datatype);
2501
- status = H5Aread (pFile->iCurrentA , memtype_id, data);
2502
- }
2503
- if (status < 0 ) {
2504
- NXReportError (" ERROR: failed to read attribute" );
2505
- return NXstatus::NX_ERROR;
2506
- }
2507
- return NXstatus::NX_OK;
2508
- }
2509
- /* ------------------------------------------------------------------------*/
2510
2346
NXstatus NX5getattrainfo (NXhandle handle, NXname name, int *rank, int dim[], NXnumtype *iType) {
2511
2347
pNexusFile5 pFile;
2512
2348
int iRet;
@@ -2605,10 +2441,7 @@ void NX5assignFunctions(pNexusFunction fHandle) {
2605
2441
fHandle ->nxnativeexternallink = NX5nativeexternallink;
2606
2442
fHandle ->nxnativeinquirefile = NX5nativeinquirefile;
2607
2443
fHandle ->nxnativeisexternallink = NX5nativeisexternallink;
2608
- fHandle ->nxputattra = NX5putattra;
2609
2444
fHandle ->nxgetnextattra = NX5getnextattra;
2610
- fHandle ->nxgetattra = NX5getattra;
2611
- fHandle ->nxgetattrainfo = NX5getattrainfo;
2612
2445
}
2613
2446
2614
2447
#endif /* HDF5 */
0 commit comments