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

Function ws_volume_prefix_len

src/foundation/workspace.c:36–63  ·  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

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

Calls 1

ws_is_sepFunction · 0.85

Tested by

no test coverage detected