MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / ws_grant_walk

Function ws_grant_walk

src/foundation/workspace.c:350–382  ·  view source on GitHub ↗

Walk the grant file, invoking visit for each entry. visit returns true to stop. * Returns the number of entries seen. */

Source from the content-addressed store, hash-verified

348/* Walk the grant file, invoking visit for each entry. visit returns true to stop.
349 * Returns the number of entries seen. */
350static int ws_grant_walk(const char *cache_dir,
351 bool (*visit)(const char *root, bool sensitive, void *ctx), void *ctx) {
352 char store[WS_LINE_MAX];
353 if (!cbm_workspace_grant_path(cache_dir, store, sizeof(store))) {
354 return 0;
355 }
356 FILE *f = cbm_fopen(store, "r");
357 if (!f) {
358 return 0;
359 }
360 char line[WS_LINE_MAX];
361 int seen = 0;
362 while (fgets(line, (int)sizeof(line), f)) {
363 size_t len = strlen(line);
364 while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r')) {
365 line[--len] = '\0';
366 }
367 if (len == 0 || line[0] == '#') {
368 continue;
369 }
370 bool sensitive = line[0] == WS_SENSITIVE_MARK;
371 const char *root = sensitive ? line + 1 : line;
372 if (!root[0]) {
373 continue;
374 }
375 seen++;
376 if (visit && visit(root, sensitive, ctx)) {
377 break;
378 }
379 }
380 (void)fclose(f);
381 return seen;
382}
383
384typedef struct {
385 const char *candidate;

Callers 3

cbm_workspace_grant_listFunction · 0.85
cbm_workspace_grant_addFunction · 0.85

Calls 2

cbm_workspace_grant_pathFunction · 0.85
cbm_fopenFunction · 0.85

Tested by

no test coverage detected