liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 0a629df48d1ea6873937a2b10432497c1fbaa24a
parent 64afd18e2ae28710dc259f3ec678c301904141cf
Author: Daniel Barlow <dan@telent.net>
Date:   Thu,  8 Aug 2024 11:36:47 +0100

anoia.fs: improve error messages

Diffstat:
Mpkgs/anoia/fs.fnl | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/pkgs/anoia/fs.fnl b/pkgs/anoia/fs.fnl @@ -9,6 +9,12 @@ (local S_IFCHR 0x2000) (local S_IFIFO 0x1000) +(macro errno-check [x] + `(match ,x + val# val# + (nil errno#) (assert nil (.. "system call failed, errno=" errno#)) + )) + (fn ifmt-bits [mode] (and mode (band mode 0xf000))) (fn file-type [pathname] @@ -33,10 +39,10 @@ (or (directory? pathname) (let [parent (string.gsub pathname "/[^/]+/?$" "")] (or (directory? parent) (mktree parent)) - (assert (ll.mkdir pathname))))) + (errno-check (ll.mkdir pathname))))) (fn dir [name] - (let [dp (assert (ll.opendir name) name)] + (let [dp (errno-check (ll.opendir name) name)] (fn [] (case (ll.readdir dp) (name filetype) (values name filetype)