MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / adfAddInCache

Function adfAddInCache

dep/adflib/src/adf_cache.c:354–434  ·  view source on GitHub ↗

* adfAddInCache * */

Source from the content-addressed store, hash-verified

352 *
353 */
354RETCODE 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);

Callers 6

adfUndelDirFunction · 0.85
adfUndelFileFunction · 0.85
adfUpdateCacheFunction · 0.85
adfRenameEntryFunction · 0.85
adfCreateDirFunction · 0.85
adfCreateFileFunction · 0.85

Calls 6

adfEntry2CacheEntryFunction · 0.85
adfReadDirCBlockFunction · 0.85
adfGetCacheEntryFunction · 0.85
adfPutCacheEntryFunction · 0.85
adfGet1FreeBlockFunction · 0.85
adfWriteDirCBlockFunction · 0.85

Tested by

no test coverage detected