feat: 新增 disk usage 内置命令(跨平台 du 等价)

- 注册表新增 Variant.Builtin 内置动作,与 Argv 互斥并参与平台匹配
- disk.usage 支持位置参数与 --path/--path=,输出按大小降序并带合计
- Unix 用设备号实现 -x 不跨文件系统,Windows 降级为不跟随 reparse point
- list/help/explain 支持展示内置动作,补充单元与 CLI 测试、README
This commit is contained in:
2026-10-31 13:11:24 +08:00
parent 7d9852958f
commit 84f7361396
12 changed files with 672 additions and 9 deletions
+26
View File
@@ -0,0 +1,26 @@
//go:build unix
package executor
import (
"os"
"syscall"
)
// deviceOf returns the device ID backing a file, used to implement du's -x
// (do not cross filesystems).
func deviceOf(info os.FileInfo) (uint64, bool) {
stat, ok := info.Sys().(*syscall.Stat_t)
if !ok {
return 0, false
}
return uint64(stat.Dev), true
}
func deviceOfPath(path string) (uint64, bool) {
info, err := os.Stat(path)
if err != nil {
return 0, false
}
return deviceOf(info)
}