feat(stdlib): Mid M2 path algebra and fs copy/move/temp
Add lib/path (EN/ZH) and thicken fs with sandboxed copy_file, move, and make_temp, with golds and public demos. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
838a2b425a
commit
94ae6713aa
22 files changed
+618
-25
No files matched your search
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Mid stdlib — path and fs
|
||||
description: lib/path + fs copy/move/temp (Mid M2)
|
||||
import path:lib/path.mq.md
|
||||
import fs:lib/fs.mq.md
|
||||
---
|
||||
|
||||
# Path algebra and file mid-layer
|
||||
|
||||
Join and normalize without plugins; copy/move stay sandboxed under the program directory.
|
||||
|
||||
# main
|
||||
|
||||
*`p` = > path.join a="out" b="demo.txt"*
|
||||
*`n` = > path.normalize path="out/./x/../demo.txt"*
|
||||
> fs.write_text path=`p` text="path-m2"
|
||||
> fs.copy_file src=`p` dest="out/demo-copy.txt"
|
||||
*`body` = > fs.read_text path="out/demo-copy.txt"*
|
||||
> print text=`p`
|
||||
> print text=`n`
|
||||
> print text=`body`
|
||||
1. `body` == "path-m2"
|
||||
> print text=mid-m2-ok
|
||||
2. *
|
||||
> print text=mid-m2-fail
|
||||
> fs.remove path=`p`
|
||||
> fs.remove path="out/demo-copy.txt"
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: 中层标准库 — 路径与文件
|
||||
description: lib/路径 + 文件复制/移动/临时(中层 M2)
|
||||
导入 路径:lib/路径.mq.md
|
||||
导入 文件:lib/文件.mq.md
|
||||
---
|
||||
|
||||
# 路径代数与文件中层
|
||||
|
||||
无插件拼接/规范化;复制/移动仍落在程序目录沙箱内。
|
||||
|
||||
# main
|
||||
|
||||
*`p` = > 路径.拼接 甲="out" 乙="demo.txt"*
|
||||
*`n` = > 路径.规范化 路径="out/./x/../demo.txt"*
|
||||
> 文件.写文本 路径=`p` 内容="path-m2"
|
||||
> 文件.复制文件 源=`p` 目标="out/demo-copy.txt"
|
||||
*`body` = > 文件.读文本 路径="out/demo-copy.txt"*
|
||||
> 打印 内容=`p`
|
||||
> 打印 内容=`n`
|
||||
> 打印 内容=`body`
|
||||
1. `body` == "path-m2"
|
||||
> 打印 内容=mid-m2-ok
|
||||
2. *
|
||||
> 打印 内容=mid-m2-fail
|
||||
> 文件.删除 路径=`p`
|
||||
> 文件.删除 路径="out/demo-copy.txt"
|
||||
Reference in new issue
Block a user