Changeset 976 for trunk/client/src/ndpsmb.c
- Timestamp:
- Aug 26, 2016, 7:04:49 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/src/ndpsmb.c
r970 r976 236 236 // and add the result to Netdrive internal list 237 237 // 238 int addFindInfoL(Connection * pConn, void * plist, smbwrp_fileinfo * finfo, ULONG ulAttribute, char * mask) 239 { 238 int addFindInfoL(Resource * pRes, void * plist, smbwrp_fileinfo * finfo, ULONG ulAttribute, char * mask) 239 { 240 debuglocal(pRes, 9, "addFindInfoL finfo %p, fname %s\n", finfo, finfo->fname); 240 241 FILESTATUS3L stat = {0}; 241 242 char * name = ph->fsphStrRChr(finfo->fname, '\\'); … … 245 246 name = finfo->fname; 246 247 247 if (!*name )248 name = p Conn->pRes->srv.share_name;248 if (!*name && pRes != NULL) 249 name = pRes->srv.share_name; 249 250 250 251 if (mask && (!ph->fsphAttrMatch(ulAttribute, finfo->attr & 0x37) || !ph->fsphWildMatch(mask, name, ND_IGNORE_CASE))) … … 255 256 stat.attrFile = (finfo->attr & 0x37); 256 257 257 fsphUnixTimeToDosDate(p Conn->pRes, finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);258 fsphUnixTimeToDosDate(p Conn->pRes, finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);259 fsphUnixTimeToDosDate(p Conn->pRes, finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);260 debuglocal(p Conn->pRes, 9, "fname %s\n", finfo->fname);261 debuglocal(p Conn->pRes, 9, "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime));262 debuglocal(p Conn->pRes, 9, "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2);258 fsphUnixTimeToDosDate(pRes, finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite); 259 fsphUnixTimeToDosDate(pRes, finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation); 260 fsphUnixTimeToDosDate(pRes, finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess); 261 debuglocal(pRes, 9, "fname %s\n", finfo->fname); 262 debuglocal(pRes, 9, "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime)); 263 debuglocal(pRes, 9, "ftimeLastAccess %02d:%02d:%02d\n", stat.ftimeLastWrite.hours, stat.ftimeLastWrite.minutes, stat.ftimeLastWrite.twosecs*2); 263 264 264 265 ph->fsphAddFile32L(plist, &stat, name, strlen(name), finfo, sizeof(*finfo), 0); 265 266 return 1; 267 } 268 269 // 270 // maps smbwrp_fileinfo data fields into a native OS/2 file informations 271 // and add the result to Netdrive internal list 272 // 273 void addFindInfoCachedL(void *plist, void* custom) 274 { 275 smbwrp_fileinfo* finfo = (smbwrp_fileinfo*)custom; 276 debuglocal(NULL, 9, "addFindInfoCachedL finfo %p, fname %s\n", finfo, finfo->fname); 277 278 // convert STATUS fields 279 FILESTATUS3L stat = {0}; 280 stat.cbFile = finfo->size; 281 stat.cbFileAlloc = stat.cbFile; 282 stat.attrFile = (finfo->attr & 0x37); 283 284 // convert timestamps 285 fsphUnixTimeToDosDate(NULL, finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite); 286 fsphUnixTimeToDosDate(NULL, finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation); 287 fsphUnixTimeToDosDate(NULL, finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess); 288 289 // add to netdrive plist 290 ph->fsphAddFile32L(plist, &stat, finfo->fname, strlen(finfo->fname), 291 finfo, sizeof(smbwrp_fileinfo), 0); 266 292 } 267 293 … … 320 346 *d++ = 0; 321 347 return; 348 } 349 350 /* callback for caching code used to free resources allocated when 351 * calling dircache_write_entry() in smbwrp.c 352 */ 353 static void cacheFreeEntry( void*custom) 354 { 355 smbwrp_fileinfo* finfo = (smbwrp_fileinfo*)custom; 356 debuglocal(NULL, 9, "cacheFreeEntry finfo %p -> %s\n", finfo, finfo->fname); 357 // release memory 358 free( finfo); 322 359 } 323 360 … … 478 515 */ 479 516 dircache_create(&pRes->pdc, (void*) pRes, 480 pRes->cachetimeout, pRes->cachedepth );517 pRes->cachetimeout, pRes->cachedepth, cacheFreeEntry); 481 518 482 519 return rc; … … 940 977 // First check if there is information in the directory cache. 941 978 unsigned long ulAge = 0; 942 if (dircache_find_path(pRes->pdc, szPath, &finfo, &ulAge)) 979 void* _finfo; 980 if (dircache_find_path(pRes->pdc, szPath, &_finfo, &ulAge)) 943 981 { 944 982 if (ulAge <= 15) /* @todo configurable. */ 945 983 { 946 984 rc = NO_ERROR; 947 finfo.easize = -1;948 addFindInfo L(pConn, plist, &finfo, 0, NULL);985 ((smbwrp_fileinfo*)_finfo)->easize = -1; 986 addFindInfoCachedL(plist, _finfo); 949 987 break; 950 988 } … … 1005 1043 { 1006 1044 finfo.easize = -1; 1007 addFindInfoL(p Conn, plist, &finfo, 0, NULL);1045 addFindInfoL(pRes, plist, &finfo, 0, NULL); 1008 1046 } 1009 1047 else if (rc == ERROR_FILE_NOT_FOUND) … … 1050 1088 Connection *pConn = (Connection *)conn; 1051 1089 Resource *pRes = pConn->pRes; 1052 int rc = NO_ERROR , count = 0;1090 int rc = NO_ERROR; 1053 1091 unsigned long action; 1054 1092 char *mask = "*"; 1055 1093 char dir[CCHMAXPATH+1] = {0}; 1056 1094 char path[CCHMAXPATH+1] = {0}; 1057 smbwrp_fileinfo * data;1058 1095 NDPATHELEMENT *pel = ph->fsphNameElem(0); 1059 1096 filelist_state state; … … 1137 1174 } 1138 1175 1139 debuglocal(pRes, 9, "NdpFindStart <%s> (%s) cnt %d %d\n", szPath, path, count, rc);1176 debuglocal(pRes, 9, "NdpFindStart <%s> (%s) rc %d\n", szPath, path, rc); 1140 1177 1141 1178 LEAVE(); … … 1816 1853 { 1817 1854 finfo.easize = -1; 1818 addFindInfoL(p Conn, plist, &finfo, 0, NULL);1855 addFindInfoL(pRes, plist, &finfo, 0, NULL); 1819 1856 } 1820 1857 } while (0);
Note:
See TracChangeset
for help on using the changeset viewer.