Windows code updates
parent
e7cc5ea6d4
commit
52c3db354b
|
@ -1,16 +0,0 @@
|
|||
USING: io.files kernel tools.test ;
|
||||
IN: temporary
|
||||
|
||||
[ "c:\\foo\\" ] [ "c:\\foo\\bar" parent-directory ] unit-test
|
||||
[ "c:\\" ] [ "c:\\foo\\" parent-directory ] unit-test
|
||||
[ "c:\\" ] [ "c:\\foo" parent-directory ] unit-test
|
||||
! { "c:" "c:\\" "c:/" } [ directory ] each -- all do the same thing
|
||||
[ "c:\\" ] [ "c:\\" parent-directory ] unit-test
|
||||
[ "Z:\\" ] [ "Z:\\" parent-directory ] unit-test
|
||||
[ "c:" ] [ "c:" parent-directory ] unit-test
|
||||
[ "Z:" ] [ "Z:" parent-directory ] unit-test
|
||||
[ t ] [ "c:\\" root-directory? ] unit-test
|
||||
[ t ] [ "Z:\\" root-directory? ] unit-test
|
||||
[ f ] [ "c:\\foo" root-directory? ] unit-test
|
||||
[ f ] [ "." root-directory? ] unit-test
|
||||
[ f ] [ ".." root-directory? ] unit-test
|
|
@ -3,6 +3,7 @@ IN: windows.errors
|
|||
|
||||
: ERROR_SUCCESS 0 ; inline
|
||||
: ERROR_HANDLE_EOF 38 ; inline
|
||||
: ERROR_BROKEN_PIPE 109 ; inline
|
||||
: ERROR_IO_INCOMPLETE 996 ; inline
|
||||
: ERROR_IO_PENDING 997 ; inline
|
||||
|
||||
|
|
|
@ -39,30 +39,21 @@ FUNCTION: void* error_message ( DWORD id ) ;
|
|||
win32-error-string throw
|
||||
] when ;
|
||||
|
||||
: (expected-io-error?) ( error-code -- ? )
|
||||
: expected-io-errors
|
||||
ERROR_SUCCESS
|
||||
ERROR_IO_INCOMPLETE
|
||||
ERROR_IO_PENDING
|
||||
WAIT_TIMEOUT 4array member? ;
|
||||
WAIT_TIMEOUT 4array ; foldable
|
||||
|
||||
: expected-io-error? ( error-code -- )
|
||||
dup (expected-io-error?) [
|
||||
: expected-io-error? ( error-code -- ? )
|
||||
expected-io-errors member? ;
|
||||
|
||||
: expected-io-error ( error-code -- )
|
||||
dup expected-io-error? [
|
||||
drop
|
||||
] [
|
||||
(win32-error-string) throw
|
||||
] if ;
|
||||
|
||||
: io-error ( return-value -- )
|
||||
{ 0 f } member? [ GetLastError expected-io-error? ] when ;
|
||||
|
||||
: overlapped-error? ( port n -- ? )
|
||||
zero? [
|
||||
GetLastError
|
||||
{
|
||||
{ [ dup (expected-io-error?) ] [ 2drop t ] }
|
||||
{ [ dup ERROR_HANDLE_EOF = ] [ drop t swap set-port-eof? f ] }
|
||||
{ [ t ] [ (win32-error-string) throw ] }
|
||||
} cond
|
||||
] [
|
||||
drop t
|
||||
] if ;
|
||||
{ 0 f } member? [ GetLastError expected-io-error ] when ;
|
||||
|
|
Loading…
Reference in New Issue