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:1269–1292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1267}
1268
1269char *cbm_fqn_module_source_lang(CBMArena *a, const char *project, const char *rel_path,
1270 CBMLanguage lang) {
1271 if (!cbm_lang_module_is_dir(lang)) {
1272 // All other languages keep the legacy filename-stem module QN.
1273 return cbm_fqn_module(a, project, rel_path);
1274 }
1275 if (!rel_path) {
1276 rel_path = "";
1277 }
1278 // Module is the CONTAINING DIRECTORY: strip the basename (last '/' segment).
1279 const char *last_slash = strrchr(rel_path, '/');
1280 if (!last_slash) {
1281 // Root file: dir is empty → module is just the project.
1282 return cbm_fqn_folder(a, project, "");
1283 }
1284 size_t dir_len = (size_t)(last_slash - rel_path);
1285 char *dir = (char *)cbm_arena_alloc(a, dir_len + SKIP_ONE);
1286 if (!dir) {
1287 return NULL;
1288 }
1289 memcpy(dir, rel_path, dir_len);
1290 dir[dir_len] = '\0';
1291 return cbm_fqn_folder(a, project, dir);
1292}
1293
1294char *cbm_fqn_compute_source_lang(CBMArena *a, const char *project, const char *rel_path,
1295 const char *name, CBMLanguage lang) {

Callers 2

cbm_extract_file_implFunction · 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