feat(stdlib): Mid2 M9 fs make_dirs, walk, and stat
Thicken lib/fs with recursive mkdir/rmdir-tree, metadata maps, and depth-first walk; add gold tests and public demos. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
435f36b6e9
commit
955834e453
16 files changed
+311
-9
No files matched your search
@@ -38,6 +38,7 @@
|
||||
| [design/stdlib-url.md](design/stdlib-url.md) | **`lib/url`(Mid2 M7)** |
|
||||
| [design/stdlib-toml.md](design/stdlib-toml.md) | **`lib/toml`(Mid2 M8)** |
|
||||
| [design/stdlib-html.md](design/stdlib-html.md) | **`lib/html`(Mid2 M8)** |
|
||||
| [design/stdlib-fs-mid2.md](design/stdlib-fs-mid2.md) | **`lib/fs` Mid2 M9 加厚** |
|
||||
| [research/stdlib-gaps-after-mid.md](research/stdlib-gaps-after-mid.md) | **Mid 之后缺口盘点**(对照 Python/Go) |
|
||||
| [roadmap/stdlib-mid.md](roadmap/stdlib-mid.md) | **Mid M1–M6 路线(done)** |
|
||||
| [roadmap/stdlib-mid2.md](roadmap/stdlib-mid2.md) | **Mid2 M7–M10 路线(规划)** |
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# 设计:`lib/fs` Mid2 加厚(M9)
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **已落地** |
|
||||
| 日期 | 2026-09-09 |
|
||||
| 父设计 | [stdlib-mid2.md](stdlib-mid2.md) §4 · [stdlib-fs-mid.md](stdlib-fs-mid.md)(M2) |
|
||||
| 宿主 | `src/host/fs.rs` · `host_make_dirs` / `host_remove_tree` / `host_stat` / `host_walk` |
|
||||
|
||||
---
|
||||
|
||||
## API
|
||||
|
||||
| EN | ZH | 行为 |
|
||||
|----|-----|------|
|
||||
| `make_dirs` | `建目录树` | 递归创建(与既有 `make_dir` 同为 `create_dir_all`;显式命名) |
|
||||
| `remove_tree` | `删目录树` | 仅删目录树;路径为文件则报错 |
|
||||
| `stat` | `状态` | `{size, mtime_unix, is_file, is_dir}` |
|
||||
| `walk` | `遍历` | **深度优先**;相对路径列表(正斜杠);含目录项;同级按名排序 |
|
||||
|
||||
既有 `remove` 对目录仍递归删除;`remove_tree` 拒绝文件,语义更窄。
|
||||
|
||||
## 刻意不做
|
||||
|
||||
ACL、watch、硬链接、`copy_tree`、惰性迭代器协议。
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **Draft · M7–M8 已落地;M9–M10 锁定方向** |
|
||||
| 状态 | **Draft · M7–M9 已落地;M10 可选** |
|
||||
| 日期 | 2026-09-09 |
|
||||
| 缺口盘点 | [stdlib-gaps-after-mid.md](../research/stdlib-gaps-after-mid.md) |
|
||||
| 路线图 | [stdlib-mid2.md](../roadmap/stdlib-mid2.md) |
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
| **配置表** | `lib/toml.mq.md` | `lib/配置表.mq.md` | **Mid2 M8** |
|
||||
| **超文本** | `lib/html.mq.md` | `lib/超文本.mq.md` | **Mid2 M8** |
|
||||
| 浏览器效应 | `lib/browser.mq.md` | `lib/浏览器.mq.md` | WASM 客户端效应助手(GFM + helpers;勿用 `json.set` 链) |
|
||||
| 文件 | `lib/fs.mq.md` | `lib/文件.mq.md` | 已有 + Mid M2:`copy_file` / `move` / `make_temp` |
|
||||
| 文件 | `lib/fs.mq.md` | `lib/文件.mq.md` | 已有 + Mid M2 + **Mid2 M9**:`make_dirs` / `remove_tree` / `stat` / `walk` |
|
||||
| 系统 | `lib/sys.mq.md` | `lib/系统.mq.md` | 已有(含 `load_dotenv`) |
|
||||
| 时间 | `lib/time.mq.md` | `lib/时间.mq.md` | 已有 |
|
||||
| JSON | `lib/json.mq.md` | **同文件** | **仅** parse / stringify / quote;集合请用 table / GFM |
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
**中层已落地:** M1–M6(含 log / uuid)— 见 [stdlib-mid.md](stdlib-mid.md) · [stdlib-log-uuid.md](stdlib-log-uuid.md)。
|
||||
|
||||
**Mid2:** **M7–M8 done**(`datetime` · `url` · `toml` · `html` · base32)— [stdlib-datetime.md](stdlib-datetime.md) · [stdlib-url.md](stdlib-url.md) · [stdlib-toml.md](stdlib-toml.md) · [stdlib-html.md](stdlib-html.md);M9+ 见 [stdlib-mid2.md](stdlib-mid2.md)。
|
||||
**Mid2:** **M7–M9 done**(datetime / url / toml / html / base32 / fs++)— [stdlib-datetime.md](stdlib-datetime.md) · [stdlib-url.md](stdlib-url.md) · [stdlib-toml.md](stdlib-toml.md) · [stdlib-html.md](stdlib-html.md) · [stdlib-fs-mid2.md](stdlib-fs-mid2.md);M10 见 [stdlib-mid2.md](stdlib-mid2.md)。
|
||||
|
||||
设计细节:[stdlib-writeback.md](stdlib-writeback.md) · [stdlib-subtask.md](stdlib-subtask.md)。
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ catalog / 工具配置若走向 TOML,只读 `toml.parse` 性价比高。YAML
|
||||
|--------|----------|------|
|
||||
| **高** | **M7** | `datetime` + `url` — **done** |
|
||||
| **高** | **M8** | `toml` 只读 + `html.escape` + `encoding` base32 — **done** |
|
||||
| **中** | **M9** | `fs` 加厚(dirs/stat/walk) |
|
||||
| **中** | **M9** | `fs` 加厚(dirs/stat/walk) — **done** |
|
||||
| **低** | **M10** | `stats` 薄 · 可选 zip · 结构化 log 字段 |
|
||||
| **won't** | — | 完整 YAML · 模板引擎 · sqlite 进 `lib/` |
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **Active · M7–M8 已落地 · M9–M10 规划** |
|
||||
| 状态 | **Active · M7–M9 已落地 · M10 可选** |
|
||||
| 日期 | 2026-09-09 |
|
||||
| 设计 | [stdlib-mid2.md](../design/stdlib-mid2.md) |
|
||||
| 缺口 | [stdlib-gaps-after-mid.md](../research/stdlib-gaps-after-mid.md) |
|
||||
@@ -54,12 +54,13 @@ M10 收口糖(可选) stats 薄 · log 字段 · (zip 默认跳过)
|
||||
| public | `15-toml-html-encoding` · `15-配置表超文本编码` |
|
||||
| 设计 | [stdlib-toml.md](../design/stdlib-toml.md) · [stdlib-html.md](../design/stdlib-html.md) |
|
||||
|
||||
### M9 — fs 加厚 — **todo**
|
||||
### M9 — fs 加厚 — **done**
|
||||
|
||||
| 交付 | 说明 |
|
||||
|------|------|
|
||||
| `make_dirs` / `remove_tree` / `stat` / `walk` | 见设计文 |
|
||||
| 金样 | `fs-mid2-smoke` |
|
||||
| `make_dirs` / `remove_tree` / `stat` / `walk` | 见 [stdlib-fs-mid2.md](../design/stdlib-fs-mid2.md) |
|
||||
| 金样 | `fs-mid2-smoke`(中英) |
|
||||
| public | `16-fs-mid2` · `16-文件mid2` |
|
||||
|
||||
### M10 — 可选收口 — **todo**
|
||||
|
||||
@@ -75,7 +76,7 @@ M10 收口糖(可选) stats 薄 · log 字段 · (zip 默认跳过)
|
||||
|
||||
- [x] M7 datetime + url
|
||||
- [x] M8 toml + html + base32
|
||||
- [ ] M9 fs 加厚
|
||||
- [x] M9 fs 加厚
|
||||
- [ ] M10 可选
|
||||
- [ ] 研究文高优先级缺口 → closed
|
||||
- [ ] `stdlib-modules.md` / `stdlib.md` 状态同步
|
||||
|
||||
Reference in new issue
Block a user