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

Function cbm_gitignore_load

src/discover/gitignore.c:313–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313cbm_gitignore_t *cbm_gitignore_load(const char *path) {
314 if (!path) {
315 return NULL;
316 }
317
318 FILE *f = cbm_fopen(path, "r");
319 if (!f) {
320 return NULL;
321 }
322
323 /* Read entire file */
324 (void)fseek(f, 0, SEEK_END);
325 long size = ftell(f);
326 (void)fseek(f, 0, SEEK_SET);
327
328 if (size <= 0) {
329 (void)fclose(f);
330 return cbm_gitignore_parse("");
331 }
332
333 char *buf = malloc(size + SKIP_ONE);
334 if (!buf) {
335 (void)fclose(f);
336 return NULL;
337 }
338
339 size_t n = fread(buf, SKIP_ONE, size, f);
340 buf[n] = '\0';
341 (void)fclose(f);
342
343 cbm_gitignore_t *gi = cbm_gitignore_parse(buf);
344 free(buf);
345 return gi;
346}
347
348/* Match a non-rooted pattern against basename and path suffixes. */
349static bool match_unrooted(const char *pattern, const char *rel_path, const char *basename) {

Callers 3

discover_implFunction · 0.85
test_gitignore.cFile · 0.85

Calls 2

cbm_fopenFunction · 0.85
cbm_gitignore_parseFunction · 0.85

Tested by

no test coverage detected