Count .db files in the cache directory. */
| 9179 | |
| 9180 | /* Count .db files in the cache directory. */ |
| 9181 | static int count_db_indexes(const char *home) { |
| 9182 | const char *cache_dir = get_cache_dir(home); |
| 9183 | if (!cache_dir) { |
| 9184 | return 0; |
| 9185 | } |
| 9186 | cbm_dir_t *d = cbm_opendir(cache_dir); |
| 9187 | if (!d) { |
| 9188 | return 0; |
| 9189 | } |
| 9190 | int count = 0; |
| 9191 | cbm_dirent_t *ent; |
| 9192 | while ((ent = cbm_readdir(d)) != NULL) { |
| 9193 | size_t len = strlen(ent->name); |
| 9194 | if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) { |
| 9195 | count++; |
| 9196 | } |
| 9197 | } |
| 9198 | cbm_closedir(d); |
| 9199 | return count; |
| 9200 | } |
| 9201 | |
| 9202 | /* Handle pre-existing indexes during (re)install (#607). |
| 9203 | * |
no test coverage detected