summaryrefslogtreecommitdiff
path: root/sanctuary.fs
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-29 20:23:28 +1100
committerkitty <nepeta@canaglie.net>2026-03-29 20:23:28 +1100
commita059eda0ecd73cbb6277da3bf64a550097bc346d (patch)
tree535a9219248ab79a8b972d129a995e6eb7439083 /sanctuary.fs
parentde41cbce8997fa2cba9047db7cc3b5d9d5aaccce (diff)
DEFER-ed words in core, file open/read/write/close
Diffstat (limited to 'sanctuary.fs')
-rw-r--r--sanctuary.fs12
1 files changed, 12 insertions, 0 deletions
diff --git a/sanctuary.fs b/sanctuary.fs
index 1aab4e2..e198710 100644
--- a/sanctuary.fs
+++ b/sanctuary.fs
@@ -74,6 +74,7 @@ decimal
r> dup >resolve 4 + ( u a )
postpone literal ( a ) drop ; immediate compile-only
: zstrlen dup begin dup c@ 0<> while 1+ repeat swap - ;
+\ todo s>z becomes s>z, s>z writes to pad (will then need to be moved below pno)
: s>z here -rot cmove, 0 c, ;
\ PRIVATISATION AND HIDING {{{
@@ -126,6 +127,12 @@ variable hld
: #> drop hld @ pad$ over - ;
\ }}}
+\ ERRNO {{{
+\ transform syscall result into [RESULT] IOR output,
+\ where IOR is zero on no error and negative on an error (RESULT then being 0)
+: >errno dup 0< if 0 swap else 0 then ;
+\ }}}
+
\ I/O {{{
0 constant stdin
1 constant stdout
@@ -142,6 +149,11 @@ variable hld
0 constant r/o
1 constant w/o
2 constant r/w
+
+: open-file swap >r 0 r> sys-open >errno ;
+: close-file sys-close ;
+: read-file >r swap r> sys-read >errno ;
+: write-file >r swap r> sys-write >errno ;
\ }}}
bye