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

Function mkc_index

tests/test_matrix_known_classes.c:91–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91static cbm_store_t *mkc_index(MKC_Proj *lp, const MKC_File *files, int nfiles) {
92 memset(lp, 0, sizeof(*lp));
93 snprintf(lp->tmpdir, sizeof(lp->tmpdir), "/tmp/cbm_mkc_XXXXXX");
94 if (!cbm_mkdtemp(lp->tmpdir))
95 return NULL;
96 mkc_to_fwd_slashes(lp->tmpdir);
97 for (int i = 0; i < nfiles; i++) {
98 char path[700];
99 snprintf(path, sizeof(path), "%s/%s", lp->tmpdir, files[i].name);
100 char *slash = strrchr(path, '/');
101 if (slash && slash > path + strlen(lp->tmpdir)) {
102 *slash = '\0';
103 cbm_mkdir_p(path, 0755);
104 *slash = '/';
105 }
106 FILE *f = fopen(path, "wb");
107 if (!f)
108 return NULL;
109 fputs(files[i].content, f);
110 fclose(f);
111 }
112 return mkc_open_indexed(lp);
113}
114
115static void mkc_cleanup(MKC_Proj *lp, cbm_store_t *store) {
116 if (store)

Callers 1

mkc_edgeFunction · 0.85

Calls 5

cbm_mkdtempFunction · 0.85
mkc_to_fwd_slashesFunction · 0.85
cbm_mkdir_pFunction · 0.85
fopenFunction · 0.85
mkc_open_indexedFunction · 0.85

Tested by

no test coverage detected