- Timestamp:
- 07/11/11 16:47:20 (7 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
src/napi5.c (modified) (7 diffs)
-
test/napi_test.c (modified) (5 diffs)
-
test/napi_test_cpp.cxx (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/napi5.c
r1738 r1741 381 381 pFile = NXI5assert (fid); 382 382 /* create and configure the group */ 383 if (pFile->iCurrentG==0) 384 { 385 iRet = H5Gcreate(pFile->iFID,(const char*)name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 383 if (pFile->iCurrentG==0) { 386 384 snprintf(pBuffer,1023,"/%s",name); 387 } else 388 { 385 } else { 389 386 snprintf(pBuffer,1023,"/%s/%s",pFile->name_ref,name); 390 iRet = H5Gcreate(pFile->iFID,(const char*)pBuffer, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);391 387 } 388 iRet = H5Gcreate(pFile->iFID,(const char*)pBuffer, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 392 389 if (iRet < 0) { 393 390 NXReportError( "ERROR: could not create Group"); … … 399 396 H5Tset_size(aid1, strlen(nxclass)); 400 397 attr1= H5Acreate(iVID, "NX_class", aid1, aid2, H5P_DEFAULT, H5P_DEFAULT); 401 if (attr1 < 0) 402 { 398 if (attr1 < 0) { 403 399 NXReportError( "ERROR: failed to store class name"); 404 400 return NX_ERROR; 405 } 406 if (H5Awrite(attr1, aid1, (char*)nxclass) < 0) 407 { 401 } 402 if (H5Awrite(attr1, aid1, (char*)nxclass) < 0) { 408 403 NXReportError( "ERROR: failed to store class name"); 409 404 return NX_ERROR; 410 }405 } 411 406 /* close group */ 412 407 iRet=H5Sclose(aid2); … … 452 447 strcpy(pFile->name_ref,pBuffer); 453 448 454 if ((nxclass != NULL) && (strcmp(nxclass, NX_UNKNOWN_GROUP) != 0)) 455 { 449 if ((nxclass != NULL) && (strcmp(nxclass, NX_UNKNOWN_GROUP) != 0)) { 456 450 /* check group attribute */ 457 451 iRet=H5Aiterate(pFile->iCurrentG,H5_INDEX_CRT_ORDER,H5_ITER_INC,0,attr_check,NULL); … … 468 462 /* check contents of group attribute */ 469 463 attr1 = H5Aopen_by_name(pFile->iCurrentG, ".", "NX_class", H5P_DEFAULT, H5P_DEFAULT); 470 if (attr1 < 0) 471 { 464 if (attr1 < 0) { 472 465 NXReportError( "ERROR: opening NX_class group attribute"); 473 466 return NX_ERROR; … … 562 555 { 563 556 hid_t type; 564 if (datatype == NX_CHAR) 565 { 557 if (datatype == NX_CHAR) { 566 558 type=H5T_C_S1; 567 } 568 else if (datatype == NX_INT8) 569 { 559 } else if (datatype == NX_INT8) { 570 560 type=H5T_NATIVE_CHAR; 571 } 572 else if (datatype == NX_UINT8) 573 { 561 } else if (datatype == NX_UINT8) { 574 562 type=H5T_NATIVE_UCHAR; 575 } 576 else if (datatype == NX_INT16) 577 { 563 } else if (datatype == NX_INT16) { 578 564 type=H5T_NATIVE_SHORT; 579 } 580 else if (datatype == NX_UINT16) 581 { 565 } else if (datatype == NX_UINT16) { 582 566 type=H5T_NATIVE_USHORT; 583 } 584 else if (datatype == NX_INT32) 585 { 567 } else if (datatype == NX_INT32) { 586 568 type=H5T_NATIVE_INT; 587 } 588 else if (datatype == NX_UINT32) 589 { 569 } else if (datatype == NX_UINT32) { 590 570 type=H5T_NATIVE_UINT; 591 } 592 else if (datatype == NX_INT64) 593 { 571 } else if (datatype == NX_INT64) { 594 572 type = H5T_NATIVE_INT64; 595 } 596 else if (datatype == NX_UINT64) 597 { 573 } else if (datatype == NX_UINT64) { 598 574 type = H5T_NATIVE_UINT64; 599 } 600 else if (datatype == NX_FLOAT32) 601 { 575 } else if (datatype == NX_FLOAT32) { 602 576 type=H5T_NATIVE_FLOAT; 603 } 604 else if (datatype == NX_FLOAT64) 605 { 577 } else if (datatype == NX_FLOAT64) { 606 578 type=H5T_NATIVE_DOUBLE; 607 } 608 else 609 { 579 } else { 610 580 NXReportError( "ERROR: nxToHDF5Type: unknown type"); 611 581 type = -1; … … 2113 2083 herr_t iRet; 2114 2084 pNexusFile5 pFile; 2115 /* char pBuffer[256]; */ 2085 char pBuffer[256]; 2086 hid_t openwhere; 2116 2087 2117 2088 pFile = NXI5assert(fileid); 2118 /* 2089 2119 2090 if (pFile->iCurrentG <= 0) { 2120 sprintf(pBuffer, "ERROR: no group open for making external link on %s", name);2121 NXReportError(pBuffer);2122 return NX_ERROR;2123 } 2124 */ 2125 iRet = H5Lcreate_external(externalfile, remotetarget, pFile->iFID, name, H5P_DEFAULT, H5P_DEFAULT);2091 openwhere = pFile->iFID; 2092 } else { 2093 openwhere = pFile->iCurrentG; 2094 } 2095 2096 iRet = H5Lcreate_external(externalfile, remotetarget, openwhere, name, H5P_DEFAULT, H5P_DEFAULT); 2126 2097 if (iRet < 0) { 2127 2098 NXReportError("ERROR: making external link failed"); … … 2141 2112 if (pFile->iCurrentD > 0) { 2142 2113 openthing = pFile->iCurrentD; 2143 } else if (pFile->iCurrentG ) {2114 } else if (pFile->iCurrentG > 0) { 2144 2115 openthing = pFile->iCurrentG; 2145 2116 } else { -
trunk/test/napi_test.c
r1739 r1741 28 28 #include <stdlib.h> 29 29 #include <string.h> 30 #include <unistd.h> 30 31 #include "napi.h" 31 32 #include "napiconfig.h" … … 34 35 static int testLoadPath(); 35 36 static int testExternal(char *progName); 37 38 char *relativePathOf(const char* filename) { 39 char cwd[1024]; 40 char *pointer; 41 42 getcwd(cwd, sizeof(cwd)); 43 44 if (strncmp(filename, cwd, strlen(cwd)) == 0) { 45 return filename+strlen(cwd)+1; 46 } 47 return filename; 48 } 36 49 37 50 int main (int argc, char *argv[]) … … 221 234 return 1; 222 235 } 223 printf("NXinquirefile found: %s\n", filename);236 printf("NXinquirefile found: %s\n", relativePathOf(filename)); 224 237 NXgetattrinfo (fileid, &i); 225 238 if (i > 0) { … … 537 550 return 1; 538 551 } 539 printf("NXinquirefile found: %s\n", filename);552 printf("NXinquirefile found: %s\n", relativePathOf(filename)); 540 553 541 554 if(NXopenpath(hfil,"/entry2/sample/sample_name") != NX_OK){ … … 550 563 return 1; 551 564 } 552 printf("NXinquirefile found: %s\n", filename);565 printf("NXinquirefile found: %s\n", relativePathOf(filename)); 553 566 554 567 if(NXopenpath(hfil,"/entry2/start_time") != NX_OK){ -
trunk/test/napi_test_cpp.cxx
r1730 r1741 16 16 using std::string; 17 17 using std::vector; 18 19 char *relativePathOf(std::string filenamestr) { 20 char cwd[1024]; 21 char *filename; 22 23 filename = strdup(filenamestr.c_str()); 24 25 getcwd(cwd, sizeof(cwd)); 26 27 //fprintf(stderr, "filename %s cwd %s\n", filename, cwd); 28 if (strncmp(filename, cwd, strlen(cwd)) == 0) { 29 return filename + strlen(cwd) + 1; 30 } 31 return filename; 32 } 18 33 19 34 int writeTest(const string& filename, NXaccess create_code) { … … 212 227 // top level file information 213 228 NeXus::File file(filename); 214 cout << "NXinquirefile found: " << file.inquireFile() << endl;229 cout << "NXinquirefile found: " << relativePathOf(file.inquireFile()) << endl; 215 230 vector<NeXus::AttrInfo> attr_infos = file.getAttrInfos(); 216 231 cout << "Number of global attributes: " << attr_infos.size() << endl; … … 475 490 filein.openPath("/entry1/start_time"); 476 491 cout << "First file time: " << filein.getStrData() << endl; 477 cout << "NXinquirefile found: " << filein.inquireFile() << endl;492 cout << "NXinquirefile found: " << relativePathOf(filein.inquireFile()) << endl; 478 493 filein.openPath("/entry2/sample/sample_name"); 479 494 cout << "Second file sample: " << filein.getStrData() << endl; 480 cout << "NXinquirefile found: " << filein.inquireFile() << endl;495 cout << "NXinquirefile found: " << relativePathOf(filein.inquireFile()) << endl; 481 496 filein.openPath("/entry2/start_time"); 482 497 cout << "Second file time: " << filein.getStrData() << endl;
Note: See TracChangeset
for help on using the changeset viewer.
