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

Function arch_path_prepare

src/store/store.c:5092–5133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5090}
5091
5092static bool arch_path_prepare(const char *path, char *norm_out, size_t norm_sz, char *like_out,
5093 size_t like_sz) {
5094 if (!arch_path_is_set(path)) {
5095 return false;
5096 }
5097 while (*path == ' ' || *path == '\t' || *path == '\n' || *path == '\r') {
5098 path++;
5099 }
5100 if (path[0] == '\0') {
5101 return false;
5102 }
5103 if (strncmp(path, "./", 2) == 0) {
5104 path += 2;
5105 }
5106 while (*path == '/') {
5107 path++;
5108 }
5109 if (path[0] == '\0') {
5110 return false;
5111 }
5112 strncpy(norm_out, path, norm_sz - 1);
5113 norm_out[norm_sz - 1] = '\0';
5114 size_t len = strlen(norm_out);
5115 while (len > 0 &&
5116 (norm_out[len - 1] == ' ' || norm_out[len - 1] == '\t' || norm_out[len - 1] == '/')) {
5117 norm_out[--len] = '\0';
5118 }
5119 /* Collapse duplicate slashes */
5120 size_t w = 0;
5121 for (size_t r = 0; norm_out[r] != '\0'; r++) {
5122 if (norm_out[r] == '/' && w > 0 && norm_out[w - 1] == '/') {
5123 continue;
5124 }
5125 norm_out[w++] = norm_out[r];
5126 }
5127 norm_out[w] = '\0';
5128 if (norm_out[0] == '\0') {
5129 return false;
5130 }
5131 snprintf(like_out, like_sz, "%s/%%", norm_out);
5132 return true;
5133}
5134
5135static const char *arch_path_scope_sql(void) {
5136 return " AND (file_path = ? OR file_path LIKE ?)";

Callers 15

arch_languagesFunction · 0.85
arch_entry_pointsFunction · 0.85
arch_routesFunction · 0.85
arch_hotspotsFunction · 0.85
arch_boundariesFunction · 0.85
arch_packages_from_qnFunction · 0.85
arch_packagesFunction · 0.85

Calls 1

arch_path_is_setFunction · 0.85

Tested by

no test coverage detected