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

Function cbm_workspace_path_depth

src/foundation/workspace.c:77–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77int cbm_workspace_path_depth(const char *canonical_path) {
78 size_t prefix = ws_volume_prefix_len(canonical_path);
79 if (prefix == 0) {
80 return 0;
81 }
82 int depth = 0;
83 const char *p = canonical_path + prefix;
84 /* macOS firmlinks /etc, /tmp and /var under /private, so canonicalizing any
85 * of them adds a component: "/etc" resolves to "/private/etc" and would count
86 * as two deep, sailing past a minimum of two — exactly the path the reports
87 * demonstrate. Treat a leading "private" as transparent so depth reflects the
88 * tree the user named. "/private/tmp/proj" still counts two and is allowed. */
89 if (strncmp(p, "private", 7) == 0 && (ws_is_sep(p[7]) || p[7] == '\0')) {
90 p += 7;
91 }
92 while (*p) {
93 while (ws_is_sep(*p)) {
94 p++;
95 }
96 if (!*p) {
97 break;
98 }
99 depth++;
100 while (*p && !ws_is_sep(*p)) {
101 p++;
102 }
103 }
104 return depth;
105}
106
107/* Case-insensitive on Windows-style paths, exact elsewhere: NTFS is
108 * case-insensitive, so ".SSH" must not slip past a case-sensitive compare. */

Callers 2

test_workspace.cFile · 0.85

Calls 2

ws_volume_prefix_lenFunction · 0.85
ws_is_sepFunction · 0.85

Tested by

no test coverage detected