Changeset 1741 for trunk


Ignore:
Timestamp:
07/11/11 16:47:20 (7 months ago)
Author:
Tobias Richter
Message:

refs #290, #299

Create link in the right place. The test creates it in the root
and that is where it always ended up by accident anyway.

fixes inquirefile tests on c
No idea what is going on in the C++ world. Should be simpler there, but not for me.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/napi5.c

    r1738 r1741  
    381381    pFile = NXI5assert (fid); 
    382382    /* 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) { 
    386384       snprintf(pBuffer,1023,"/%s",name); 
    387     } else 
    388     { 
     385    } else { 
    389386       snprintf(pBuffer,1023,"/%s/%s",pFile->name_ref,name); 
    390        iRet = H5Gcreate(pFile->iFID,(const char*)pBuffer, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 
    391387    }    
     388    iRet = H5Gcreate(pFile->iFID,(const char*)pBuffer, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); 
    392389    if (iRet < 0) { 
    393390      NXReportError( "ERROR: could not create Group"); 
     
    399396    H5Tset_size(aid1, strlen(nxclass)); 
    400397    attr1= H5Acreate(iVID, "NX_class", aid1, aid2, H5P_DEFAULT, H5P_DEFAULT); 
    401     if (attr1 < 0) 
    402        { 
     398    if (attr1 < 0) { 
    403399       NXReportError( "ERROR: failed to store class name"); 
    404400       return NX_ERROR; 
    405        } 
    406     if (H5Awrite(attr1, aid1, (char*)nxclass) < 0) 
    407       { 
     401    } 
     402    if (H5Awrite(attr1, aid1, (char*)nxclass) < 0) { 
    408403      NXReportError( "ERROR: failed to store class name"); 
    409404      return NX_ERROR; 
    410       } 
     405    } 
    411406    /* close group */ 
    412407    iRet=H5Sclose(aid2); 
     
    452447    strcpy(pFile->name_ref,pBuffer); 
    453448 
    454     if ((nxclass != NULL) && (strcmp(nxclass, NX_UNKNOWN_GROUP) != 0)) 
    455     { 
     449    if ((nxclass != NULL) && (strcmp(nxclass, NX_UNKNOWN_GROUP) != 0)) { 
    456450        /* check group attribute */ 
    457451        iRet=H5Aiterate(pFile->iCurrentG,H5_INDEX_CRT_ORDER,H5_ITER_INC,0,attr_check,NULL); 
     
    468462        /* check contents of group attribute */ 
    469463        attr1 = H5Aopen_by_name(pFile->iCurrentG, ".", "NX_class", H5P_DEFAULT, H5P_DEFAULT); 
    470         if (attr1 < 0) 
    471         { 
     464        if (attr1 < 0) { 
    472465              NXReportError( "ERROR: opening NX_class group attribute"); 
    473466              return NX_ERROR;  
     
    562555{ 
    563556  hid_t type; 
    564     if (datatype == NX_CHAR) 
    565     { 
     557    if (datatype == NX_CHAR) { 
    566558        type=H5T_C_S1; 
    567     } 
    568     else if (datatype == NX_INT8) 
    569     { 
     559    } else if (datatype == NX_INT8) { 
    570560        type=H5T_NATIVE_CHAR; 
    571     } 
    572     else if (datatype == NX_UINT8) 
    573     { 
     561    } else if (datatype == NX_UINT8) { 
    574562        type=H5T_NATIVE_UCHAR; 
    575     } 
    576     else if (datatype == NX_INT16) 
    577     { 
     563    } else if (datatype == NX_INT16) { 
    578564        type=H5T_NATIVE_SHORT; 
    579     } 
    580     else if (datatype == NX_UINT16) 
    581     { 
     565    } else if (datatype == NX_UINT16) { 
    582566        type=H5T_NATIVE_USHORT; 
    583     } 
    584     else if (datatype == NX_INT32) 
    585     { 
     567    } else if (datatype == NX_INT32) { 
    586568        type=H5T_NATIVE_INT; 
    587     } 
    588     else if (datatype == NX_UINT32) 
    589     { 
     569    } else if (datatype == NX_UINT32) { 
    590570        type=H5T_NATIVE_UINT; 
    591     } 
    592     else if (datatype == NX_INT64) 
    593     { 
     571    } else if (datatype == NX_INT64) { 
    594572        type = H5T_NATIVE_INT64; 
    595     } 
    596     else if (datatype == NX_UINT64) 
    597     { 
     573    } else if (datatype == NX_UINT64) { 
    598574        type = H5T_NATIVE_UINT64; 
    599     } 
    600     else if (datatype == NX_FLOAT32) 
    601     { 
     575    } else if (datatype == NX_FLOAT32) { 
    602576        type=H5T_NATIVE_FLOAT; 
    603     } 
    604     else if (datatype == NX_FLOAT64) 
    605     { 
     577    } else if (datatype == NX_FLOAT64) { 
    606578        type=H5T_NATIVE_DOUBLE; 
    607     } 
    608     else 
    609     { 
     579    } else { 
    610580      NXReportError( "ERROR: nxToHDF5Type: unknown type"); 
    611581      type = -1; 
     
    21132083     herr_t iRet; 
    21142084     pNexusFile5 pFile; 
    2115      /* char pBuffer[256]; */ 
     2085     char pBuffer[256];  
     2086     hid_t openwhere; 
    21162087 
    21172088     pFile = NXI5assert(fileid); 
    2118 /* 
     2089 
    21192090      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); 
    21262097     if (iRet < 0) { 
    21272098       NXReportError("ERROR: making external link failed"); 
     
    21412112      if (pFile->iCurrentD > 0) { 
    21422113          openthing = pFile->iCurrentD; 
    2143       } else if (pFile->iCurrentG) { 
     2114      } else if (pFile->iCurrentG > 0) { 
    21442115          openthing = pFile->iCurrentG; 
    21452116      } else { 
  • trunk/test/napi_test.c

    r1739 r1741  
    2828#include <stdlib.h> 
    2929#include <string.h> 
     30#include <unistd.h> 
    3031#include "napi.h" 
    3132#include "napiconfig.h" 
     
    3435static int testLoadPath(); 
    3536static int testExternal(char *progName); 
     37 
     38char *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} 
    3649 
    3750int main (int argc, char *argv[]) 
     
    221234    return 1; 
    222235  } 
    223   printf("NXinquirefile found: %s\n", filename); 
     236  printf("NXinquirefile found: %s\n", relativePathOf(filename)); 
    224237  NXgetattrinfo (fileid, &i); 
    225238  if (i > 0) { 
     
    537550    return 1; 
    538551  } 
    539   printf("NXinquirefile found: %s\n", filename); 
     552  printf("NXinquirefile found: %s\n", relativePathOf(filename)); 
    540553 
    541554  if(NXopenpath(hfil,"/entry2/sample/sample_name") != NX_OK){ 
     
    550563    return 1; 
    551564  } 
    552   printf("NXinquirefile found: %s\n", filename); 
     565  printf("NXinquirefile found: %s\n", relativePathOf(filename)); 
    553566 
    554567  if(NXopenpath(hfil,"/entry2/start_time") != NX_OK){ 
  • trunk/test/napi_test_cpp.cxx

    r1730 r1741  
    1616using std::string; 
    1717using std::vector; 
     18 
     19char *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} 
    1833 
    1934int writeTest(const string& filename, NXaccess create_code) { 
     
    212227  // top level file information 
    213228  NeXus::File file(filename); 
    214   cout << "NXinquirefile found: " << file.inquireFile() << endl; 
     229  cout << "NXinquirefile found: " << relativePathOf(file.inquireFile()) << endl; 
    215230  vector<NeXus::AttrInfo> attr_infos = file.getAttrInfos(); 
    216231  cout << "Number of global attributes: " << attr_infos.size() << endl; 
     
    475490  filein.openPath("/entry1/start_time"); 
    476491  cout << "First file time: " << filein.getStrData() << endl; 
    477   cout << "NXinquirefile found: " << filein.inquireFile() << endl; 
     492  cout << "NXinquirefile found: " << relativePathOf(filein.inquireFile()) << endl; 
    478493  filein.openPath("/entry2/sample/sample_name"); 
    479494  cout << "Second file sample: " << filein.getStrData() << endl; 
    480   cout << "NXinquirefile found: " << filein.inquireFile() << endl; 
     495  cout << "NXinquirefile found: " << relativePathOf(filein.inquireFile()) << endl; 
    481496  filein.openPath("/entry2/start_time"); 
    482497  cout << "Second file time: " << filein.getStrData() << endl; 
Note: See TracChangeset for help on using the changeset viewer.