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

Function detect_file_language

src/discover/discover.c:570–585  ·  view source on GitHub ↗

Detect language for a file, handling .m disambiguation and JSON filtering. */

Source from the content-addressed store, hash-verified

568
569/* Detect language for a file, handling .m disambiguation and JSON filtering. */
570static CBMLanguage detect_file_language(const char *entry_name, const char *abs_path) {
571 CBMLanguage lang = cbm_language_for_filename(entry_name);
572 if (lang == CBM_LANG_COUNT) {
573 return CBM_LANG_COUNT;
574 }
575 /* Special: .m files need content-based disambiguation */
576 const char *dot = strrchr(entry_name, '.');
577 if (dot && strcmp(dot, ".m") == 0) {
578 lang = cbm_disambiguate_m(abs_path);
579 }
580 /* Check ignored JSON files */
581 if (lang == CBM_LANG_JSON && str_in_list(entry_name, IGNORED_JSON_FILES)) {
582 return CBM_LANG_COUNT;
583 }
584 return lang;
585}
586
587/* UTF-8-safe stat: wide API on Windows, regular stat on POSIX. */
588static int wide_stat(const char *path, struct stat *st) {

Callers 1

walk_dir_process_fileFunction · 0.85

Calls 3

cbm_disambiguate_mFunction · 0.85
str_in_listFunction · 0.85

Tested by

no test coverage detected