feat: add Directory.list() foreign method and async directory listing to io module

This commit is contained in:
Bob Nystrom
2015-12-27 04:42:53 +00:00
17 changed files with 175 additions and 41 deletions
+1
View File
@@ -0,0 +1 @@
this is a text file
+1
View File
@@ -0,0 +1 @@
this is a text file
+1
View File
@@ -0,0 +1 @@
this is a text file
+8
View File
@@ -0,0 +1,8 @@
import "io" for Directory
var entries = Directory.list("test/io/directory/dir")
// Ignore OS-specific dot files like ".DS_Store".
entries = entries.where {|entry| !entry.startsWith(".") }.toList
System.print(entries) // expect: [a.txt, b.txt, c.txt]
+3
View File
@@ -0,0 +1,3 @@
import "io" for Directory
var entries = Directory.list("test/io/directory/dir/a.txt") // expect runtime error: not a directory
+3
View File
@@ -0,0 +1,3 @@
import "io" for Directory
Directory.list("nonexistent") // expect runtime error: no such file or directory
@@ -0,0 +1,3 @@
import "io" for Directory
Directory.list(123) // expect runtime error: Path must be a string.