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

Function count_db_indexes

src/cli/cli.c:10375–10394  ·  view source on GitHub ↗

Count .db files in the cache directory. */

Source from the content-addressed store, hash-verified

10373
10374/* Count .db files in the cache directory. */
10375static int count_db_indexes(const char *home) {
10376 const char *cache_dir = get_cache_dir(home);
10377 if (!cache_dir) {
10378 return 0;
10379 }
10380 cbm_dir_t *d = cbm_opendir(cache_dir);
10381 if (!d) {
10382 return 0;
10383 }
10384 int count = 0;
10385 cbm_dirent_t *ent;
10386 while ((ent = cbm_readdir(d)) != NULL) {
10387 size_t len = strlen(ent->name);
10388 if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) {
10389 count++;
10390 }
10391 }
10392 cbm_closedir(d);
10393 return count;
10394}
10395
10396/* Handle pre-existing indexes during (re)install (#607).
10397 *

Callers 6

cli_install_activateFunction · 0.85
cli_uninstall_activateFunction · 0.85
cbm_cmd_uninstallFunction · 0.85

Calls 4

get_cache_dirFunction · 0.85
cbm_opendirFunction · 0.85
cbm_readdirFunction · 0.85
cbm_closedirFunction · 0.85

Tested by

no test coverage detected