* adfAddInCache * */
| 352 | * |
| 353 | */ |
| 354 | RETCODE adfAddInCache(struct Volume *vol, struct bEntryBlock *parent, |
| 355 | struct bEntryBlock *entry) |
| 356 | { |
| 357 | struct bDirCacheBlock dirc, newDirc; |
| 358 | SECTNUM nSect, nCache; |
| 359 | struct CacheEntry caEntry, newEntry; |
| 360 | int offset, n; |
| 361 | int entryLen; |
| 362 | |
| 363 | entryLen = adfEntry2CacheEntry(entry, &newEntry); |
| 364 | /*printf("adfAddInCache--%4ld %2d %6ld %8lx %4d %2d:%02d:%02d %30s %22s\n", |
| 365 | newEntry.header, newEntry.type, newEntry.size, newEntry.protect, |
| 366 | newEntry.days, newEntry.mins/60, newEntry.mins%60, |
| 367 | newEntry.ticks/50, |
| 368 | newEntry.name, newEntry.comm); |
| 369 | */ |
| 370 | nSect = parent->extension; |
| 371 | do { |
| 372 | if (adfReadDirCBlock(vol, nSect, &dirc)!=RC_OK) |
| 373 | return RC_ERROR; |
| 374 | offset = 0; n = 0; |
| 375 | /*printf("parent=%4ld\n",dirc.parent);*/ |
| 376 | while(n < dirc.recordsNb) { |
| 377 | adfGetCacheEntry(&dirc, &offset, &caEntry); |
| 378 | /*printf("*%4ld %2d %6ld %8lx %4d %2d:%02d:%02d %30s %22s\n", |
| 379 | caEntry.header, caEntry.type, caEntry.size, caEntry.protect, |
| 380 | caEntry.days, caEntry.mins/60, caEntry.mins%60, |
| 381 | caEntry.ticks/50, |
| 382 | caEntry.name, caEntry.comm); |
| 383 | */ |
| 384 | n++; |
| 385 | } |
| 386 | |
| 387 | /* if (offset+entryLen<=488) { |
| 388 | adfPutCacheEntry(&dirc, &offset, &newEntry); |
| 389 | dirc.recordsNb++; |
| 390 | adfWriteDirCBlock(vol, dirc.headerKey, &dirc); |
| 391 | return rc; |
| 392 | }*/ |
| 393 | nSect = dirc.nextDirC; |
| 394 | }while(nSect!=0); |
| 395 | |
| 396 | /* in the last block */ |
| 397 | if (offset+entryLen<=488) { |
| 398 | adfPutCacheEntry(&dirc, &offset, &newEntry); |
| 399 | dirc.recordsNb++; |
| 400 | /*printf("entry name=%s\n",newEntry.name);*/ |
| 401 | } |
| 402 | else { |
| 403 | /* request one new block free */ |
| 404 | nCache = adfGet1FreeBlock(vol); |
| 405 | if (nCache==-1) { |
| 406 | (*adfEnv.wFct)("adfCreateDir : nCache==-1"); |
| 407 | return RC_VOLFULL; |
| 408 | } |
| 409 | |
| 410 | /* create a new dircache block */ |
| 411 | memset(&newDirc,0,512); |
no test coverage detected