errno {
{ EINTR [ 2drop +retry+ ] }
{ EAGAIN [ 2drop +input+ ] }
- [ (io-error) ]
+ [ throw-errno ]
} case
] if ;
errno {
{ EINTR [ 2drop +retry+ ] }
{ EAGAIN [ 2drop +output+ ] }
- [ (io-error) ]
+ [ throw-errno ]
} case
] if ;
stdin data>> handle-fd buffer buffer-end size read
dup 0 < [
drop
- errno EINTR = [ buffer stdin size refill-stdin ] [ (io-error) ] if
+ errno EINTR = [
+ buffer stdin size refill-stdin
+ ] [
+ throw-errno
+ ] if
] [
size = [ "Error reading stdin pipe" throw ] unless
size buffer buffer+
: multiplexer-error ( n -- n )
dup 0 < [
errno [ EAGAIN = ] [ EINTR = ] bi or
- [ drop 0 ] [ (io-error) ] if
+ [ drop 0 ] [ throw-errno ] if
] when ;
:: ?flag ( n mask symbol -- n )
: with-unix-directory ( path quot -- )
dupd '[ _ _
- [ opendir dup [ (io-error) ] unless ] dip
+ [ opendir dup [ throw-errno ] unless ] dip
dupd curry swap '[ _ closedir io-error ] [ ] cleanup
] with-directory ; inline
: access? ( path mode -- ? )
[ normalize-path ] [ access ] bi* 0 < [
- errno EACCES = [ f ] [ (io-error) ] if
+ errno EACCES = [ f ] [ throw-errno ] if
] [ t ] if ;
PRIVATE>
M: unix cwd ( -- path )
MAXPATHLEN [ <byte-array> ] keep
[ getcwd ] unix-system-call
- [ (io-error) ] unless* ;
+ [ throw-errno ] unless* ;
M: unix cd ( path -- ) [ chdir ] unix-system-call drop ;
[
f length prot flags
path open-mode file-mode open-file [ <fd> |dispose drop ] keep
- [ 0 mmap dup MAP_FAILED = [ (io-error) ] when ] keep
+ [ 0 mmap dup MAP_FAILED = [ throw-errno ] when ] keep
] with-destructors ;
M: unix (mapped-file-r/w)
: syscall-error ( r -- event )
ERR_get_error [
{
- { -1 [ errno ECONNRESET = [ premature-close ] [ (io-error) ] if ] }
+ { -1 [ errno ECONNRESET = [ premature-close ] [ throw-errno ] if ] }
! OpenSSL docs say this it is an error condition for
! a server to not send a close notify, but web
! servers in the wild don't seem to do this, for
errno {
{ EAGAIN [ wait-for-output ] }
{ EINTR [ wait-to-connect ] }
- [ (io-error) ]
+ [ throw-errno ]
} case
] if ;
errno {
{ EINTR [ establish-connection ] }
{ EINPROGRESS [ drop wait-for-output ] }
- [ (io-error) ]
+ [ throw-errno ]
} case
] if ;
[ (accept) ]
2bi
] }
- [ (io-error) ]
+ [ throw-errno ]
} case
] if ;
datagram +output+ wait-for-port
packet sockaddr len socket datagram do-send
] }
- [ (io-error) ]
+ [ throw-errno ]
} case
] when ; inline recursive
ERROR: libc-error errno message ;
-: (io-error) ( -- * ) errno dup strerror libc-error ;
+: throw-errno ( -- * ) errno dup strerror libc-error ;
-: io-error ( n -- ) 0 < [ (io-error) ] when ;
+: io-error ( n -- ) 0 < [ throw-errno ] when ;
<PRIVATE
! [ uuid_string_t <struct> [ mbr_uuid_to_string io-error ] keep ]
} case ;
-: acl-error ( n -- ) -1 = [ (io-error) ] when ; inline
+: acl-error ( n -- ) -1 = [ throw-errno ] when ; inline
:: file-acl ( path -- acl_t/f )
path
clear-errno
ACL_TYPE_EXTENDED acl_get_file dup [
errno ENOENT = [
- [ path exists? ] preserve-errno [ drop f ] [ (io-error) ] if
+ [ path exists? ] preserve-errno
+ [ drop f ] [ throw-errno ] if
] [
- (io-error)
+ throw-errno
] if
] unless ;