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

Function ha_canonical_path

src/cli/hook_augment.c:725–749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725static bool ha_canonical_path(const char *input, char *output, size_t output_size) {
726 if (!input || !output || output_size == 0U || !cbm_hook_path_is_abs(input)) {
727 return false;
728 }
729 char resolved[4096];
730#ifdef _WIN32
731 const char *source = _fullpath(resolved, input, sizeof(resolved)) ? resolved : input;
732#else
733 const char *source = realpath(input, resolved) ? resolved : input;
734#endif
735 int written = snprintf(output, output_size, "%s", source);
736 if (written < 0 || (size_t)written >= output_size) {
737 return false;
738 }
739 for (char *cursor = output; *cursor; cursor++) {
740 if (*cursor == '\\') {
741 *cursor = '/';
742 }
743 }
744 size_t length = strlen(output);
745 while (length > 1U && output[length - 1U] == '/' && !(length == 3U && output[1] == ':')) {
746 output[--length] = '\0';
747 }
748 return cbm_hook_path_is_abs(output);
749}
750
751static bool ha_path_contains_mode(const char *root, const char *candidate, bool case_insensitive) {
752 if (!root || !candidate) {

Callers 3

ha_resolve_coverageFunction · 0.85

Calls 1

cbm_hook_path_is_absFunction · 0.85

Tested by

no test coverage detected