Add Directory.list() to io.

This commit is contained in:
Bob Nystrom
2015-12-24 10:12:12 -08:00
parent 1ebc711c30
commit 0ac793d4f8
11 changed files with 188 additions and 56 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.