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

Function adfGetDirEntCache

dep/adflib/src/adf_cache.c:59–131  ·  view source on GitHub ↗

* adfGetDirEntCache * * replace 'adfGetDirEnt'. returns a the dir contents based on the dircache list */

Source from the content-addressed store, hash-verified

57 * replace 'adfGetDirEnt'. returns a the dir contents based on the dircache list
58 */
59struct List* adfGetDirEntCache(struct Volume *vol, SECTNUM dir, BOOL recurs)
60{
61 struct bEntryBlock parent;
62 struct bDirCacheBlock dirc;
63 int offset, n;
64 struct List *cell, *head;
65 struct CacheEntry caEntry;
66 struct Entry *entry;
67 SECTNUM nSect;
68
69 if (adfReadEntryBlock(vol,dir,&parent)!=RC_OK)
70 return NULL;
71
72 nSect = parent.extension;
73
74 cell = head = NULL;
75 do {
76 /* one loop per cache block */
77 n = offset = 0;
78 if (adfReadDirCBlock(vol, nSect, &dirc)!=RC_OK)
79 return NULL;
80 while (n<dirc.recordsNb) {
81 /* one loop per record */
82 entry = (struct Entry*)malloc(sizeof(struct Entry));
83 if (!entry) {
84 adfFreeDirList(head);
85 return NULL;
86 }
87 adfGetCacheEntry(&dirc, &offset, &caEntry);
88
89 /* converts a cache entry into a dir entry */
90 entry->type = (int)caEntry.type;
91 entry->name = strdup(caEntry.name);
92 if (entry->name==NULL) {
93 free(entry); adfFreeDirList(head);
94 return NULL;
95 }
96 entry->sector = caEntry.header;
97 entry->comment = strdup(caEntry.comm);
98 if (entry->comment==NULL) {
99 free(entry->name); adfFreeDirList(head);
100 return NULL;
101 }
102 entry->size = caEntry.size;
103 entry->access = caEntry.protect;
104 adfDays2Date( caEntry.days, &(entry->year), &(entry->month),
105 &(entry->days) );
106 entry->hour = caEntry.mins/60;
107 entry->mins = caEntry.mins%60;
108 entry->secs = caEntry.ticks/50;
109
110 /* add it into the linked list */
111 if (head==NULL)
112 head = cell = newCell(NULL, (void*)entry);
113 else
114 cell = newCell(cell, (void*)entry);
115
116 if (cell==NULL) {

Callers 1

adfGetRDirEntFunction · 0.85

Calls 7

adfReadEntryBlockFunction · 0.85
adfReadDirCBlockFunction · 0.85
adfFreeDirListFunction · 0.85
adfGetCacheEntryFunction · 0.85
adfDays2DateFunction · 0.85
newCellFunction · 0.85
adfFreeEntryFunction · 0.85

Tested by

no test coverage detected