File Predicates¶
There are the usual pathname predicates such as f?
, d?
and
r?
which are comparable to familiar shell predicates -f
,
-d
and -r
.
define (test-for fn) {
(cond
((f? fn) {
printf "%s is a file\n" fn
})
((d? fn) {
printf "%s is a directory\n" fn
})
(else {
printf "%s is beyond knowledge\n" fn
}))
}
fn := "words.txt"
test-for "."
;; just in case
if (f? fn) (delete-file fn)
test-for fn
touch fn
test-for fn
$ idio file-predicates
. is a directory
words.txt is beyond knowledge
words.txt is a file
Last built at 2024-10-13T06:11:41Z+0000 from 77077af (dev) for Idio 0.3