Changeset 1731
- Timestamp:
- 02/11/11 18:08:42 (7 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
include/napi.h (modified) (3 diffs)
-
src/napi.c (modified) (3 diffs)
-
src/napi5.c (modified) (2 diffs)
-
src/nexus_symbols.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/napi.h
r1728 r1731 246 246 # define NXinquirefile MANGLE(nxiinquirefile) 247 247 # define NXisexternalgroup MANGLE(nxiisexternalgroup) 248 # define NXisexternaldataset MANGLE(nxiisexternaldataset) 248 249 # define NXlinkexternal MANGLE(nxilinkexternal) 249 250 # define NXlinkexternaldataset MANGLE(nxilinkexternaldataset) … … 723 724 extern NXstatus NXisexternalgroup(NXhandle handle, CONSTCHAR *name, CONSTCHAR *nxclass, char *url, int urlLen); 724 725 726 727 /** 728 * Test if a dataset is actually pointing to an external file. If so, retrieve the URL of the 729 * external file. 730 * \param handle A NeXus file handle as initialized by NXopen. 731 * \param name The name of the dataset to test. 732 * \param url A buffer to copy the URL too. 733 * \param urlLen The length of the Url buffer. At maximum urlLen bytes will be copied to url. 734 * \return NX_OK when the dataset is pointing to an external file, NX_ERROR else. 735 * \ingroup c_external 736 */ 737 extern NXstatus NXisexternaldataset(NXhandle handle, CONSTCHAR *name, char *url, int urlLen); 738 725 739 /** 726 740 * Create a link to a group in an external file. This works by creating a NeXus group under the current level in 727 * the hierarchy which actually points to a group in another file.741 * the hierarchy which actually points to a group in another file. 728 742 * \param handle A NeXus file handle as initialized by NXopen. 729 743 * \param name The name of the group which points to the external file. … … 905 919 NXstatus ( *nxprintlink)(NXhandle handle, NXlink* link); 906 920 NXstatus ( *nxnativeexternallink)(NXhandle handle, CONSTCHAR* name, CONSTCHAR* externalfile, CONSTCHAR* remotetarget); 921 NXstatus ( *nxnativeinquirefile)(NXhandle handle, char* externalfile, const int filenamelength); 922 NXstatus ( *nxnativeisexternallink)(NXhandle handle, CONSTCHAR* name, char* url, int urllen); 907 923 } NexusFunction, *pNexusFunction; 908 924 /*---------------------*/ -
trunk/src/napi.c
r1729 r1731 1278 1278 pFileStack fileStack; 1279 1279 char *pPtr = NULL; 1280 int length; 1280 int length, status; 1281 1282 pNexusFunction pFunc = handleToNexusFunc(handle); 1283 if (pFunc->nxnativeinquirefile != NULL) { 1284 1285 status = LOCKED_CALL(pFunc->nxnativeinquirefile(pFunc->pNexusData, filename, filenameBufferLength)); 1286 if (status < 0) { 1287 return NX_ERROR; 1288 } else { 1289 return NX_OK; 1290 } 1291 1292 } 1281 1293 1282 1294 fileStack = (pFileStack)handle; … … 1302 1314 pNexusFunction pFunc = handleToNexusFunc(fid); 1303 1315 1304 status = LOCKED_CALL(pFunc->nxopengroup(pFunc->pNexusData, name,nxclass)); 1316 if (pFunc->nxnativeisexternallink != NULL) { 1317 status = LOCKED_CALL(pFunc->nxnativeisexternallink(pFunc->pNexusData, name, url, urlLen)); 1318 if (status == NX_OK) { 1319 return NX_OK; 1320 } 1321 // need to continue, could still be old style link 1322 } 1323 1324 status = LOCKED_CALL(pFunc->nxopengroup(pFunc->pNexusData, name, nxclass)); 1305 1325 if(status != NX_OK){ 1306 1326 return status; … … 1323 1343 } 1324 1344 /*------------------------------------------------------------------------*/ 1325 NXstatus NXlinkexternal(NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass, CONSTCHAR *url){ 1345 NXstatus NXisexternaldataset(NXhandle fid, CONSTCHAR *name, 1346 char *url, int urlLen){ 1347 int status, attStatus, length = 1023, type = NX_CHAR; 1348 char nxurl[1024]; 1349 1350 pNexusFunction pFunc = handleToNexusFunc(fid); 1351 1352 if (pFunc->nxnativeisexternallink != NULL) { 1353 status = LOCKED_CALL(pFunc->nxnativeisexternallink(pFunc->pNexusData, name, url, urlLen)); 1354 if (status == NX_OK) { 1355 return NX_OK; 1356 } 1357 // need to continue, could still be old style link 1358 } 1359 1360 status = LOCKED_CALL(pFunc->nxopendata(pFunc->pNexusData, name)); 1361 if(status != NX_OK){ 1362 return status; 1363 } 1364 NXMDisableErrorReporting(); 1365 attStatus = NXgetattr(fid,"napimount",nxurl,&length, &type); 1366 NXMEnableErrorReporting(); 1367 LOCKED_CALL(pFunc->nxclosedata(pFunc->pNexusData)); 1368 if(attStatus == NX_OK){ 1369 length = strlen(nxurl); 1370 if(length > urlLen){ 1371 length = urlLen - 1; 1372 } 1373 memset(url,0,urlLen); 1374 memcpy(url,nxurl,length); 1375 return attStatus; 1376 } else { 1377 return NX_ERROR; 1378 } 1379 } 1380 /*------------------------------------------------------------------------*/ 1381 NXstatus NXlinkexternal(NXhandle fid, CONSTCHAR *name, CONSTCHAR *nxclass, CONSTCHAR *url) { 1326 1382 int status, type = NX_CHAR, length=1024, urllen; 1327 1383 char nxurl[1024], exfile[512], expath[512]; -
trunk/src/napi5.c
r1730 r1731 2105 2105 /* ------------------------------------------------------------------- */ 2106 2106 2107 NXstatus NX5nativeinquirefile(NXhandle fileid, char* externalfile, const int filenamelen) 2108 { 2109 pNexusFile5 pFile; 2110 ssize_t name_size; 2111 2112 pFile = NXI5assert(fileid); 2113 2114 name_size = H5Fget_name(pFile->iFID, externalfile, filenamelen); 2115 2116 // Check for failure again 2117 if( name_size < 0 ) { 2118 NXReportError("ERROR: retrieving file name"); 2119 return NX_ERROR; 2120 } 2121 return NX_OK; 2122 } 2123 /* ------------------------------------------------------------------- */ 2124 2125 NXstatus NX5nativeisexternallink(NXhandle fileid, const char* name, char* url, const int urllen) 2126 { 2127 pNexusFile5 pFile; 2128 herr_t ret; 2129 H5L_info_t link_buff; 2130 int size=1024; 2131 char linkval_buff[size]; 2132 const char *filepath, *objpath; 2133 2134 pFile = NXI5assert(fileid); 2135 2136 ret = H5Lget_info(pFile->iFID, name, &link_buff, H5P_DEFAULT); 2137 if (ret < 0 || link_buff.type != H5L_TYPE_EXTERNAL) { 2138 return NX_ERROR; 2139 } 2140 2141 ret = H5Lget_val(pFile->iFID, name, linkval_buff, size, H5P_DEFAULT); 2142 if (ret < 0) { 2143 return NX_ERROR; 2144 } 2145 2146 ret = H5Lunpack_elink_val(linkval_buff, size, 0, &filepath, &objpath); 2147 if (ret < 0 || link_buff.type != H5L_TYPE_EXTERNAL) { 2148 return NX_ERROR; 2149 } 2150 2151 snprintf(url, urllen, "nxfile://%s#%s", filepath, objpath); 2152 return NX_OK; 2153 2154 } 2155 /* ------------------------------------------------------------------- */ 2156 2107 2157 NXstatus NX5sameID (NXhandle fileid, NXlink* pFirstID, NXlink* pSecondID) 2108 2158 { … … 2170 2220 fHandle->nxprintlink=NX5printlink; 2171 2221 fHandle->nxnativeexternallink=NX5nativeexternallink; 2172 // fHandle->nxnativeexternallink=NULL; 2222 fHandle->nxnativeinquirefile=NX5nativeinquirefile; 2223 fHandle->nxnativeisexternallink=NX5nativeisexternallink; 2173 2224 } 2174 2225 -
trunk/src/nexus_symbols.txt
r1687 r1731 52 52 nxiinquirefile_ 53 53 nxiisexternalgroup_ 54 nxiisexternaldataset_ 54 55 NXMSetError 55 56 NXMSetTError
Note: See TracChangeset
for help on using the changeset viewer.
