Check that file exists: Difference between revisions
added langur language example
m (→{{header|Wren}}: Changed to Wren S/H) |
Langurmonkey (talk | contribs) (added langur language example) |
||
Line 1,944:
[[io]]::fp.existsFile($dir2)
[[io]]::fp.closeFile($dir2)
</syntaxhighlight>
=={{header|langur}}==
Use the prop() function, which returns a hash of file/directory properties.
{{works with|langur|0.12.7}}
<syntaxhighlight lang="langur">val .printresult = f(.file) {
write .file, ": "
if val .p = prop(.file) {
if .p'isdir {
writeln "is directory"
} else {
writeln "is file"
}
} else {
writeln "nothing"
}
}
.printresult("input.txt")
.printresult("/input.txt")
.printresult("docs")
.printresult("/docs")
</syntaxhighlight>
|