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

Function cp_index_files

tests/test_convergence_probe.c:219–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219static cbm_store_t *cp_index_files(CP_Proj *lp, const CP_File *files, int nfiles) {
220 memset(lp, 0, sizeof(*lp));
221 snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_cp_XXXXXX");
222 if (!cbm_mkdtemp(lp->tmpdir)) return NULL;
223 cp_to_fwd_slashes(lp->tmpdir);
224 for (int i = 0; i < nfiles; i++) {
225 char path[700];
226 snprintf(path, sizeof(path), "%s/%s", lp->tmpdir, files[i].name);
227 char *slash = strrchr(path, '/');
228 if (slash && slash > path + strlen(lp->tmpdir)) {
229 *slash = '\0';
230 cbm_mkdir_p(path, 0755);
231 *slash = '/';
232 }
233 FILE *f = fopen(path, "wb");
234 if (!f) return NULL;
235 fputs(files[i].content, f);
236 fclose(f);
237 }
238 return cp_open_indexed(lp);
239}
240
241static void cp_cleanup(CP_Proj *lp, cbm_store_t *store) {
242 if (store) cbm_store_close(store);

Callers 2

cp_index_parallelFunction · 0.85

Calls 4

cbm_mkdtempFunction · 0.85
cp_to_fwd_slashesFunction · 0.85
cbm_mkdir_pFunction · 0.85
cp_open_indexedFunction · 0.85

Tested by

no test coverage detected