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

Function cbm_gitignore_load

src/discover/gitignore.c:286–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286cbm_gitignore_t *cbm_gitignore_load(const char *path) {
287 if (!path) {
288 return NULL;
289 }
290
291 FILE *f = cbm_fopen(path, "r");
292 if (!f) {
293 return NULL;
294 }
295
296 /* Read entire file */
297 (void)fseek(f, 0, SEEK_END);
298 long size = ftell(f);
299 (void)fseek(f, 0, SEEK_SET);
300
301 if (size <= 0) {
302 (void)fclose(f);
303 return cbm_gitignore_parse("");
304 }
305
306 char *buf = malloc(size + SKIP_ONE);
307 if (!buf) {
308 (void)fclose(f);
309 return NULL;
310 }
311
312 size_t n = fread(buf, SKIP_ONE, size, f);
313 buf[n] = '\0';
314 (void)fclose(f);
315
316 cbm_gitignore_t *gi = cbm_gitignore_parse(buf);
317 free(buf);
318 return gi;
319}
320
321/* Match a non-rooted pattern against basename and path suffixes. */
322static bool match_unrooted(const char *pattern, const char *rel_path, const char *basename) {

Callers 3

cbm_discover_exFunction · 0.85
test_gitignore.cFile · 0.85

Calls 2

cbm_fopenFunction · 0.85
cbm_gitignore_parseFunction · 0.85

Tested by

no test coverage detected