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

Function hl_count_strays

tests/test_cli.c:16131–16158  ·  view source on GitHub ↗

Entries under dir that are neither keep_a, keep_b nor one of their * ancestors: whatever the hook created. Each is printed by its tail. */

Source from the content-addressed store, hash-verified

16129/* Entries under dir that are neither keep_a, keep_b nor one of their
16130 * ancestors: whatever the hook created. Each is printed by its tail. */
16131static int hl_count_strays(const char *dir, const char *keep_a, const char *keep_b) {
16132 cbm_dir_t *d = cbm_opendir(dir);
16133 if (!d) {
16134 return 0;
16135 }
16136 int strays = 0;
16137 cbm_dirent_t *entry;
16138 while ((entry = cbm_readdir(d)) != NULL) {
16139 if (strcmp(entry->name, ".") == 0 || strcmp(entry->name, "..") == 0) {
16140 continue;
16141 }
16142 char child[HL_PATH_CAP];
16143 int n = snprintf(child, sizeof(child), "%s/%s", dir, entry->name);
16144 bool named = n > 0 && (size_t)n < sizeof(child);
16145 if (named &&
16146 (hl_is_ancestor_or_self(child, keep_a) || hl_is_ancestor_or_self(child, keep_b))) {
16147 if (entry->is_dir) {
16148 strays += hl_count_strays(child, keep_a, keep_b);
16149 }
16150 continue;
16151 }
16152 size_t len = named ? (size_t)n : strlen(child);
16153 printf(" stray entry: ...%s\n", child + (len > 60 ? len - 60 : 0));
16154 strays++;
16155 }
16156 cbm_closedir(d);
16157 return strays;
16158}
16159#endif
16160
16161/* A HOME of ~1 KiB: the log path "<HOME>/.cache/codebase-memory-mcp/logs/

Callers 1

test_cli.cFile · 0.85

Calls 4

cbm_opendirFunction · 0.85
cbm_readdirFunction · 0.85
hl_is_ancestor_or_selfFunction · 0.85
cbm_closedirFunction · 0.85

Tested by

no test coverage detected