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

Function ws_volume_prefix_len

src/foundation/workspace.c:35–62  ·  view source on GitHub ↗

Length of the volume prefix: "/" on POSIX, "C:/" for a drive, "//srv/share" * for a UNC share. Returns 0 when the path is not absolute. */

Source from the content-addressed store, hash-verified

33/* Length of the volume prefix: "/" on POSIX, "C:/" for a drive, "//srv/share"
34 * for a UNC share. Returns 0 when the path is not absolute. */
35static size_t ws_volume_prefix_len(const char *path) {
36 if (!path || !path[0]) {
37 return 0;
38 }
39 /* UNC: two separators, a host, then a share. */
40 if (ws_is_sep(path[0]) && ws_is_sep(path[1])) {
41 size_t i = 2;
42 while (path[i] && !ws_is_sep(path[i])) { /* host */
43 i++;
44 }
45 while (ws_is_sep(path[i])) {
46 i++;
47 }
48 while (path[i] && !ws_is_sep(path[i])) { /* share */
49 i++;
50 }
51 return i;
52 }
53 if (ws_is_sep(path[0])) {
54 return 1;
55 }
56 /* Drive-letter root, with or without a trailing separator. */
57 if (path[1] == ':' &&
58 ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z'))) {
59 return ws_is_sep(path[2]) ? 3 : 2;
60 }
61 return 0;
62}
63
64static bool ws_is_unc(const char *path) {
65 return path && ws_is_sep(path[0]) && ws_is_sep(path[1]);

Callers 4

cbm_workspace_path_depthFunction · 0.85
ws_any_component_matchesFunction · 0.85

Calls 1

ws_is_sepFunction · 0.85

Tested by

no test coverage detected