Empty directory: Difference between revisions
Added Wren
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
(Added Wren) |
||
Line 1,151:
False
True
</pre>
=={{header|Wren}}==
<lang ecmascript>import "io" for Directory
var isEmptyDir = Fn.new { |path|
if (!Directory.exists(path)) Fiber.abort("Directory at '%(path)' does not exist.")
return Directory.list(path).count == 0
}
var path = "test"
var empty = isEmptyDir.call(path)
System.print("'%(path)' is %(empty ? "empty" : "not empty")")</lang>
{{out}}
'test' is an empty directory I made earlier.
<pre>
'test' is empty
</pre>
|