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

Function arch_path_prepare

src/store/store.c:4982–5023  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4980}
4981
4982static bool arch_path_prepare(const char *path, char *norm_out, size_t norm_sz, char *like_out,
4983 size_t like_sz) {
4984 if (!arch_path_is_set(path)) {
4985 return false;
4986 }
4987 while (*path == ' ' || *path == '\t' || *path == '\n' || *path == '\r') {
4988 path++;
4989 }
4990 if (path[0] == '\0') {
4991 return false;
4992 }
4993 if (strncmp(path, "./", 2) == 0) {
4994 path += 2;
4995 }
4996 while (*path == '/') {
4997 path++;
4998 }
4999 if (path[0] == '\0') {
5000 return false;
5001 }
5002 strncpy(norm_out, path, norm_sz - 1);
5003 norm_out[norm_sz - 1] = '\0';
5004 size_t len = strlen(norm_out);
5005 while (len > 0 &&
5006 (norm_out[len - 1] == ' ' || norm_out[len - 1] == '\t' || norm_out[len - 1] == '/')) {
5007 norm_out[--len] = '\0';
5008 }
5009 /* Collapse duplicate slashes */
5010 size_t w = 0;
5011 for (size_t r = 0; norm_out[r] != '\0'; r++) {
5012 if (norm_out[r] == '/' && w > 0 && norm_out[w - 1] == '/') {
5013 continue;
5014 }
5015 norm_out[w++] = norm_out[r];
5016 }
5017 norm_out[w] = '\0';
5018 if (norm_out[0] == '\0') {
5019 return false;
5020 }
5021 snprintf(like_out, like_sz, "%s/%%", norm_out);
5022 return true;
5023}
5024
5025static const char *arch_path_scope_sql(void) {
5026 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