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

Function count_db_indexes

src/cli/cli.c:9029–9048  ·  view source on GitHub ↗

Count .db files in the cache directory. */

Source from the content-addressed store, hash-verified

9027
9028/* Count .db files in the cache directory. */
9029static int count_db_indexes(const char *home) {
9030 const char *cache_dir = get_cache_dir(home);
9031 if (!cache_dir) {
9032 return 0;
9033 }
9034 cbm_dir_t *d = cbm_opendir(cache_dir);
9035 if (!d) {
9036 return 0;
9037 }
9038 int count = 0;
9039 cbm_dirent_t *ent;
9040 while ((ent = cbm_readdir(d)) != NULL) {
9041 size_t len = strlen(ent->name);
9042 if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) {
9043 count++;
9044 }
9045 }
9046 cbm_closedir(d);
9047 return count;
9048}
9049
9050/* Handle pre-existing indexes during (re)install (#607).
9051 *

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