| 645 | #include <dirent.h> |
| 646 | |
| 647 | static void append_roots_json(char *buf, size_t bufsz, int *pos) { |
| 648 | http_appendf(buf, bufsz, pos, ",\"roots\":["); |
| 649 | #ifdef _WIN32 |
| 650 | DWORD drives = GetLogicalDrives(); |
| 651 | int count = 0; |
| 652 | for (int i = 0; i < 26; i++) { |
| 653 | if (!(drives & (1u << i))) { |
| 654 | continue; |
| 655 | } |
| 656 | if (count++ > 0) { |
| 657 | buf[(*pos)++] = ','; |
| 658 | } |
| 659 | http_appendf(buf, bufsz, pos, "\"%c:/\"", 'A' + i); |
| 660 | } |
| 661 | #else |
| 662 | http_appendf(buf, bufsz, pos, "\"/\""); |
| 663 | #endif |
| 664 | http_appendf(buf, bufsz, pos, "]"); |
| 665 | } |
| 666 | |
| 667 | /* GET /api/browse?path=/some/dir — list subdirectories for file picker */ |
| 668 | static void handle_browse(cbm_http_conn_t *c, const cbm_http_req_t *req) { |
no test coverage detected