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

Function append_roots_json

src/ui/http_server.c:1237–1265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1235/* ── Directory browser ────────────────────────────────────────── */
1236
1237static void append_roots_json(char *buf, size_t bufsz, int *pos) {
1238 http_appendf(buf, bufsz, pos, ",\"roots\":[");
1239#ifdef _WIN32
1240 DWORD drives = GetLogicalDrives();
1241 int count = 0;
1242 for (int i = 0; i < 26; i++) {
1243 if (!(drives & (1u << i))) {
1244 continue;
1245 }
1246 /* Advertise exactly what /api/browse will accept: a mounted letter
1247 * without a readable medium (empty optical drive, unformatted or
1248 * offline volume) fails the same cbm_is_dir gate browse applies, and
1249 * a root the picker cannot open must not be offered. */
1250 char root[4] = {(char)('A' + i), ':', '/', '\0'};
1251 if (!cbm_is_dir(root)) {
1252 continue;
1253 }
1254 if (count++ > 0) {
1255 /* Once a wide listing saturates buf, http_appendf has already
1256 * pinned *pos to bufsz, so this separator goes through it too. */
1257 http_appendf(buf, bufsz, pos, ",");
1258 }
1259 http_appendf(buf, bufsz, pos, "\"%c:/\"", 'A' + i);
1260 }
1261#else
1262 http_appendf(buf, bufsz, pos, "\"/\"");
1263#endif
1264 http_appendf(buf, bufsz, pos, "]");
1265}
1266
1267/* GET /api/browse?path=/some/dir — list subdirectories for file picker */
1268static void handle_browse(cbm_http_conn_t *c, const cbm_http_req_t *req) {

Callers 1

handle_browseFunction · 0.85

Calls 2

http_appendfFunction · 0.85
cbm_is_dirFunction · 0.85

Tested by

no test coverage detected