windows.shell32: Throw an error if file does not exist on file-executable?

call.
db4
Doug Coleman 2012-10-24 17:47:30 -07:00
parent 83b40e44d2
commit 43fb3fb174
1 changed files with 21 additions and 16 deletions

View File

@ -5,7 +5,7 @@ alien.syntax classes.struct combinators io.backend io.files
io.pathnames kernel math sequences specialized-arrays io.pathnames kernel math sequences specialized-arrays
ui.backend.windows windows windows.com windows.com.syntax ui.backend.windows windows windows.com windows.com.syntax
windows.errors windows.kernel32 windows.ole32 windows.types windows.errors windows.kernel32 windows.ole32 windows.types
windows.user32 ; windows.user32 io.files.info ;
SPECIALIZED-ARRAY: ushort SPECIALIZED-ARRAY: ushort
IN: windows.shell32 IN: windows.shell32
@ -143,11 +143,15 @@ INSTANCE: +win32-os2-executable+ windows-executable ! ne
INSTANCE: +win32-nt-executable+ windows-executable ! pe INSTANCE: +win32-nt-executable+ windows-executable ! pe
: file-executable-type ( path -- executable/f ) : file-executable-type ( path -- executable/f )
normalize-path normalize-path dup
0 0
f f
! hi is zero means old style executable ! hi is zero means old style executable
0 SHGFI_EXETYPE SHGetFileInfoW >lo-hi first2 zero? [ 0 SHGFI_EXETYPE SHGetFileInfoW
[
file-info drop f
] [
nip >lo-hi first2 zero? [
{ {
{ 0x5A4D [ +dos-executable+ ] } { 0x5A4D [ +dos-executable+ ] }
{ 0x4550 [ +win32-console-executable+ ] } { 0x4550 [ +win32-console-executable+ ] }
@ -160,7 +164,8 @@ INSTANCE: +win32-nt-executable+ windows-executable ! pe
{ 0x4550 [ +win32-nt-executable+ ] } { 0x4550 [ +win32-nt-executable+ ] }
[ drop f ] [ drop f ]
} case } case
] if ; ] if
] if-zero ;
: shell32-directory ( n -- str ) : shell32-directory ( n -- str )
f swap f SHGFP_TYPE_DEFAULT f swap f SHGFP_TYPE_DEFAULT