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.
file-predicates.idio¶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 2025-11-14T07:11:17Z+0000 from 77077af (dev) for Idio 0.3