09-路径文件ok
Structure
import路径:lib/路径.mq.md文件:lib/文件.mq.md
fn · h1路径代数与文件中层
comment
fn · h1main
bind
`p` = > 路径.拼接 甲=out 乙=demo.txtbind
`n` = > 路径.规范化 路径=out/./x/../demo.txtcall
> 文件.写文本 路径=`p` 内容=path-m2call
> 文件.复制文件 源=`p` 目标=out/demo-copy.txtbind
`body` = > 文件.读文本 路径=out/demo-copy.txtcall
> 打印 内容=`p`call
> 打印 内容=`n`call
> 打印 内容=`body`branch
arm
`body` == path-m2call
> 打印 内容=mid-m2-okarm
elsecall
> 打印 内容=mid-m2-failcall
> 文件.删除 路径=`p`call
> 文件.删除 路径=out/demo-copy.txtExecution
out/demo.txt
out/demo.txt
path-m2
mid-m2-ok
Source
--- 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"
无插件拼接/规范化;复制/移动仍落在程序目录沙箱内。