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

Function cx_copy_entry

tests/test_complexity.c:220–247  ·  view source on GitHub ↗

A fixture entry into `dst`: a file, or a directory with its contents. */

Source from the content-addressed store, hash-verified

218
219/* A fixture entry into `dst`: a file, or a directory with its contents. */
220static int cx_copy_entry(const char *src, const char *dst, bool is_dir) {
221 if (!is_dir) {
222 return cx_copy_file(src, dst);
223 }
224 if (th_mkdir_p(dst) != 0) {
225 return -1;
226 }
227 cbm_dir_t *d = cbm_opendir(src);
228 if (!d) {
229 return -1;
230 }
231 int rc = 0;
232 cbm_dirent_t *entry;
233 while ((entry = cbm_readdir(d)) != NULL) {
234 if (entry->name[0] == '.') {
235 continue;
236 }
237 char from[1024];
238 char to[1024];
239 snprintf(from, sizeof(from), "%s/%s", src, entry->name);
240 snprintf(to, sizeof(to), "%s/%s", dst, entry->name);
241 if (cx_copy_entry(from, to, entry->is_dir) != 0) {
242 rc = -1;
243 }
244 }
245 cbm_closedir(d);
246 return rc;
247}
248
249/* ── Corpus builder ──────────────────────────────────────────────────── */
250

Callers 1

cx_build_corpusFunction · 0.85

Calls 5

cx_copy_fileFunction · 0.85
th_mkdir_pFunction · 0.85
cbm_opendirFunction · 0.85
cbm_readdirFunction · 0.85
cbm_closedirFunction · 0.85

Tested by

no test coverage detected