-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.groovy
52 lines (41 loc) · 1.19 KB
/
test.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 打印FISH对象
println "FISH: " + FISH
// 打印当前工作目录
println "CWD: " + CWD
// 获取上级目录
println "PARENT: " + FILE(CWD + "../")
// 获取下级文件列表
println "LIST src/:"
println LIST(CWD + "src/")
// 获取文件树
println "TREE src/:"
println TREE(CWD + "src/")
// 遍历文件树
println "FILES src/:"
FILES(TREE(CWD + "src/")).each { file ->
if (file.regularFile) {
// 打印普通文件
println file
// 打印文件属性
println STAT(file)
}
}
// 读取文本文件内容
println "READ test.groovy:"
println READ(CWD + "test.groovy")
// 写入文本文件内容
println "WRITE test.txt:"
println WRITE(CWD + "test.txt", "hello world!")
// 复制文件
println "COPY test.txt -> test-copy.txt:"
println COPY(CWD + "test.txt", CWD + "test-copy.txt")
// 移动文件
println "MOVE test-copy.txt -> test-move.txt:"
println MOVE(CWD + "test-copy.txt", CWD + "test-move.txt")
// 删除文件
println "DELETE test-move.txt: "
println DELETE(CWD + "test-move.txt")
// 安装校验和工具命令
INSTALL "cc.whohow.fs.shell.provider.checksum.Checksum"
// 计算文件MD5值
println "MD5 test.groovy: " + Checksum("MD5", CWD + "test.groovy")