improve file-exists? function

This commit is contained in:
Daniel Barlow 2023-06-18 17:41:09 +01:00
parent 80639a7256
commit a65bb9d585

View file

@ -37,10 +37,10 @@
(fn file-exists? [name]
(let [f (io.open name :r)]
(match f
non-nil (or (f:close) true)
(nil err) false)))
(match (io.open name :r)
f (do (f:close) true)
_ false))
(fn read-line [name]
(with-open [f (assert (io.open name :r) (.. "can't open file " name))]