feat: add File.stat static method and test for directory stat

Add a new `File.stat(path)` static method that returns a `Stat` object with low-level file system metadata for both files and directories. Include a test file `stat_static_directory.wren` that validates the returned `Stat` object's type and field types (device, inode, mode, linkCount, user, group, specialDevice, size, blockSize, blockCount) against a known test directory.
This commit is contained in:
Bob Nystrom
2016-01-01 18:05:31 +00:00
parent f112722d00
commit 7186b04bed
2 changed files with 23 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import "io" for File, Stat
import "scheduler" for Scheduler
var stat = File.stat("test/io/directory/dir")
System.print(stat is Stat) // expect: true
System.print(stat.device is Num) // expect: true
System.print(stat.inode is Num) // expect: true
System.print(stat.mode is Num) // expect: true
System.print(stat.linkCount) // expect: 5
System.print(stat.user is Num) // expect: true
System.print(stat.group is Num) // expect: true
System.print(stat.specialDevice) // expect: 0
System.print(stat.size) // expect: 170
System.print(stat.blockSize is Num) // expect: true
System.print(stat.blockCount is Num) // expect: true