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:
cflmyandCursor committed 2026-09-09 09:27:06 +08:00
1 parent 435f36b6e9
commit 955834e453
16 files changed
+311 -9

No files matched your search

+13
View File
@@ -1229,6 +1229,19 @@ fn lib_toml_html_encoding_smoke_zh() {
);
}
#[test]
fn lib_fs_mid2_smoke() {
assert_out(
"tests/lib/fs-mid2-smoke.mq.md",
"1\nTrue\nFalse\n3\na.txt\nnested\nnested/b.txt\nFalse",
);
}
#[test]
fn lib_fs_mid2_smoke_zh() {
assert_out("tests/lib/文件-mid2-烟测.mq.md", "True\n2\nFalse");
}
#[test]
fn lib_re_smoke() {
assert_out(
+32
View File
@@ -0,0 +1,32 @@
---
title: fs mid2 M9 smoke
import fs:lib/fs.mq.md
---
# main
> fs.make_dirs path="m9-tree/nested"
> fs.write_text path="m9-tree/a.txt" text="A"
> fs.write_text path="m9-tree/nested/b.txt" text="B"
*st = > fs.stat path="m9-tree/a.txt"*
> print text=`st`[^size]
> print text=`st`[^is_file]
> print text=`st`[^is_dir]
*w = > fs.walk path="m9-tree"*
*n = > len `w`*
> print text=`n`
*p0 = > at value=`w` index=0*
*p1 = > at value=`w` index=1*
*p2 = > at value=`w` index=2*
> print text=`p0`
> print text=`p1`
> print text=`p2`
> fs.remove_tree path="m9-tree"
*gone = > fs.exists path="m9-tree"*
> print text=`gone`
+22
View File
@@ -0,0 +1,22 @@
---
title: 文件 Mid2 M9 烟测
导入 文件:lib/文件.mq.md
---
# main
> 文件.建目录树 路径="m9-zh/子"
> 文件.写文本 路径="m9-zh/a.txt" 内容="A"
*st = > 文件.状态 路径="m9-zh/a.txt"*
> print text=`st`[^is_file]
*w = > 文件.遍历 路径="m9-zh"*
*n = > 长度 `w`*
> print text=`n`
> 文件.删目录树 路径="m9-zh"
*gone = > 文件.存在 路径="m9-zh"*
> print text=`gone`