Count .db files in the cache directory. */
| 9241 | |
| 9242 | /* Count .db files in the cache directory. */ |
| 9243 | static int count_db_indexes(const char *home) { |
| 9244 | const char *cache_dir = get_cache_dir(home); |
| 9245 | if (!cache_dir) { |
| 9246 | return 0; |
| 9247 | } |
| 9248 | cbm_dir_t *d = cbm_opendir(cache_dir); |
| 9249 | if (!d) { |
| 9250 | return 0; |
| 9251 | } |
| 9252 | int count = 0; |
| 9253 | cbm_dirent_t *ent; |
| 9254 | while ((ent = cbm_readdir(d)) != NULL) { |
| 9255 | size_t len = strlen(ent->name); |
| 9256 | if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) { |
| 9257 | count++; |
| 9258 | } |
| 9259 | } |
| 9260 | cbm_closedir(d); |
| 9261 | return count; |
| 9262 | } |
| 9263 | |
| 9264 | /* Handle pre-existing indexes during (re)install (#607). |
| 9265 | * |
no test coverage detected