] [ rethrow ] if
] recover ;
-M: unix cwd ( -- path )
+M: unix cwd
4096 (cwd) ;
-M: unix cd ( path -- ) [ chdir ] unix-system-call drop ;
+M: unix cd [ chdir ] unix-system-call drop ;
CONSTANT: read-flags flags{ O_RDONLY }
: open-read ( path -- fd ) read-flags file-mode open-file ;
-M: unix (file-reader) ( path -- stream )
+M: unix (file-reader)
open-read <fd> init-fd <input-port> ;
CONSTANT: write-flags flags{ O_WRONLY O_CREAT O_TRUNC }
: open-write ( path -- fd )
write-flags file-mode open-file ;
-M: unix (file-writer) ( path -- stream )
+M: unix (file-writer)
open-write <fd> init-fd <output-port> ;
CONSTANT: append-flags flags{ O_WRONLY O_APPEND O_CREAT }
dup 0 SEEK_END [ lseek ] unix-system-call drop
] with-destructors ;
-M: unix (file-appender) ( path -- stream )
+M: unix (file-appender)
open-append <fd> init-fd <output-port> ;
M: unix home "HOME" os-env ;