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

Function resolve_from_path

src/ui/http_server.c:1500–1523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1498}
1499
1500static bool resolve_from_path(const char *name, char *out, size_t outsz) {
1501 const char *path = getenv("PATH");
1502 if (!name || !name[0] || strchr(name, '/') || !path || !path[0]) {
1503 return false;
1504 }
1505
1506 const char *cur = path;
1507 while (*cur) {
1508 const char *colon = strchr(cur, ':');
1509 size_t dir_len = colon ? (size_t)(colon - cur) : strlen(cur);
1510 if (dir_len > 0 && dir_len < 900) {
1511 char candidate[1024];
1512 int n = snprintf(candidate, sizeof(candidate), "%.*s/%s", (int)dir_len, cur, name);
1513 if (n > 0 && (size_t)n < sizeof(candidate) && is_executable_file(candidate)) {
1514 return copy_path(out, outsz, candidate);
1515 }
1516 }
1517 if (!colon) {
1518 break;
1519 }
1520 cur = colon + 1;
1521 }
1522 return false;
1523}
1524
1525static bool resolve_self_executable(char *out, size_t outsz) {
1526#if defined(__APPLE__)

Callers 1

Calls 2

is_executable_fileFunction · 0.85
copy_pathFunction · 0.85

Tested by

no test coverage detected