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

Function arch_path_prepare

src/store/store.c:8235–8276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8233}
8234
8235static bool arch_path_prepare(const char *path, char *norm_out, size_t norm_sz, char *like_out,
8236 size_t like_sz) {
8237 if (!arch_path_is_set(path)) {
8238 return false;
8239 }
8240 while (*path == ' ' || *path == '\t' || *path == '\n' || *path == '\r') {
8241 path++;
8242 }
8243 if (path[0] == '\0') {
8244 return false;
8245 }
8246 if (strncmp(path, "./", 2) == 0) {
8247 path += 2;
8248 }
8249 while (*path == '/') {
8250 path++;
8251 }
8252 if (path[0] == '\0') {
8253 return false;
8254 }
8255 strncpy(norm_out, path, norm_sz - 1);
8256 norm_out[norm_sz - 1] = '\0';
8257 size_t len = strlen(norm_out);
8258 while (len > 0 &&
8259 (norm_out[len - 1] == ' ' || norm_out[len - 1] == '\t' || norm_out[len - 1] == '/')) {
8260 norm_out[--len] = '\0';
8261 }
8262 /* Collapse duplicate slashes */
8263 size_t w = 0;
8264 for (size_t r = 0; norm_out[r] != '\0'; r++) {
8265 if (norm_out[r] == '/' && w > 0 && norm_out[w - 1] == '/') {
8266 continue;
8267 }
8268 norm_out[w++] = norm_out[r];
8269 }
8270 norm_out[w] = '\0';
8271 if (norm_out[0] == '\0') {
8272 return false;
8273 }
8274 snprintf(like_out, like_sz, "%s/%%", norm_out);
8275 return true;
8276}
8277
8278static const char *arch_path_scope_sql(void) {
8279 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