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

Function cbm_gitignore_load

src/discover/gitignore.c:100–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100cbm_gitignore_t *cbm_gitignore_load(const char *path) {
101 if (!path) {
102 return NULL;
103 }
104
105 FILE *f = cbm_fopen(path, "r");
106 if (!f) {
107 return NULL;
108 }
109
110 /* Read entire file */
111 (void)fseek(f, 0, SEEK_END);
112 long size = ftell(f);
113 (void)fseek(f, 0, SEEK_SET);
114
115 if (size <= 0) {
116 (void)fclose(f);
117 return cbm_gitignore_parse("");
118 }
119
120 char *buf = malloc(size + SKIP_ONE);
121 if (!buf) {
122 (void)fclose(f);
123 return NULL;
124 }
125
126 size_t n = fread(buf, SKIP_ONE, size, f);
127 buf[n] = '\0';
128 (void)fclose(f);
129
130 cbm_gitignore_t *gi = cbm_gitignore_parse(buf);
131 free(buf);
132 return gi;
133}
134
135int cbm_gitignore_match_result(const cbm_gitignore_t *gi, const char *rel_path, bool is_dir) {
136 if (!gi || !rel_path) {

Callers 4

ancestor_ignores_buildFunction · 0.85
discover_implFunction · 0.85
test_gitignore.cFile · 0.85

Calls 3

cbm_fopenFunction · 0.85
cbm_gitignore_parseFunction · 0.85
freadFunction · 0.85

Tested by

no test coverage detected