Improve file/directory utils (#84)

This commit is contained in:
Josh Goebel
2021-05-01 15:58:17 -07:00
committed by GitHub
parent 4acf7b395d
commit 8227330eb6
7 changed files with 125 additions and 56 deletions
+23
View File
@@ -0,0 +1,23 @@
import "io" for Directory, Stat
import "os" for Platform
if (Directory.exists("tmp")) {
Directory.delete("tmp")
}
System.print(Directory.exists("tmp")) // expect: false
Directory.create("tmp")
System.print(Directory.exists("tmp")) // expect: true
// Windows does not support mode
if (Platform.isPosix) {
var stat = Stat.path("tmp")
// 511 is 0755
System.print(stat.mode && 0x1ff) // expect: 511
}
Directory.delete("tmp")
System.print(Directory.exists("tmp")) // expect: false