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

Function cbm_fqn_module_source_lang

internal/cbm/helpers.c:1451–1474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1449}
1450
1451char *cbm_fqn_module_source_lang(CBMArena *a, const char *project, const char *rel_path,
1452 CBMLanguage lang) {
1453 if (!cbm_lang_module_is_dir(lang)) {
1454 // All other languages keep the legacy filename-stem module QN.
1455 return cbm_fqn_module(a, project, rel_path);
1456 }
1457 if (!rel_path) {
1458 rel_path = "";
1459 }
1460 // Module is the CONTAINING DIRECTORY: strip the basename (last '/' segment).
1461 const char *last_slash = strrchr(rel_path, '/');
1462 if (!last_slash) {
1463 // Root file: dir is empty → module is just the project.
1464 return cbm_fqn_folder(a, project, "");
1465 }
1466 size_t dir_len = (size_t)(last_slash - rel_path);
1467 char *dir = (char *)cbm_arena_alloc(a, dir_len + SKIP_ONE);
1468 if (!dir) {
1469 return NULL;
1470 }
1471 memcpy(dir, rel_path, dir_len);
1472 dir[dir_len] = '\0';
1473 return cbm_fqn_folder(a, project, dir);
1474}
1475
1476char *cbm_fqn_compute_source_lang(CBMArena *a, const char *project, const char *rel_path,
1477 const char *name, CBMLanguage lang) {

Callers 2

cbm_extract_file_exFunction · 0.85

Calls 4

cbm_lang_module_is_dirFunction · 0.85
cbm_fqn_moduleFunction · 0.85
cbm_fqn_folderFunction · 0.85
cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected