| 595 | } |
| 596 | |
| 597 | static int rmdir_recursive(const char *path) { |
| 598 | char stack[RMDIR_STACK_CAP][CLI_BUF_1K]; |
| 599 | int top = 0; |
| 600 | snprintf(stack[top++], CLI_BUF_1K, "%s", path); |
| 601 | |
| 602 | /* Post-order: collect all dirs depth-first, then rmdir in reverse. */ |
| 603 | char dirs[RMDIR_STACK_CAP][CLI_BUF_1K]; |
| 604 | int dir_count = 0; |
| 605 | |
| 606 | while (top > 0) { |
| 607 | char *cur = stack[--top]; |
| 608 | if (dir_count < RMDIR_STACK_CAP) { |
| 609 | snprintf(dirs[dir_count++], CLI_BUF_1K, "%s", cur); |
| 610 | } |
| 611 | rmdir_scan_dir(cur, stack, &top); |
| 612 | } |
| 613 | /* Remove dirs in reverse (deepest first). */ |
| 614 | int rc = 0; |
| 615 | for (int i = dir_count - CLI_SKIP_ONE; i >= 0; i--) { |
| 616 | if (cbm_rmdir(dirs[i]) != 0) { |
| 617 | rc = CBM_NOT_FOUND; |
| 618 | } |
| 619 | } |
| 620 | return rc; |
| 621 | } |
| 622 | |
| 623 | /* ── Skill management ─────────────────────────────────────────── */ |
| 624 |
no test coverage detected