diff --git a/core/io/files/files.factor b/core/io/files/files.factor index 1dd4259bb6..03bcb77731 100755 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -126,3 +126,17 @@ TUPLE: pathname string ; C: pathname M: pathname <=> [ pathname-string ] compare ; + +HOOK: library-roots io-backend ( -- seq ) +HOOK: binary-roots io-backend ( -- seq ) + +: find-file ( seq str -- path/f ) + [ + [ path+ exists? ] curry find nip + ] keep over [ path+ ] [ drop ] if ; + +: find-library ( str -- path/f ) + library-roots swap find-file ; + +: find-binary ( str -- path/f ) + binary-roots swap find-file ; diff --git a/extra/io/windows/windows.factor b/extra/io/windows/windows.factor index d112a99cae..2defa48298 100755 --- a/extra/io/windows/windows.factor +++ b/extra/io/windows/windows.factor @@ -4,13 +4,23 @@ USING: alien alien.c-types arrays destructors io io.backend io.buffers io.files io.nonblocking io.sockets io.binary io.sockets.impl windows.errors strings io.streams.duplex kernel math namespaces sequences windows windows.kernel32 -windows.winsock splitting ; +windows.shell32 windows.winsock splitting ; IN: io.windows TUPLE: windows-nt-io ; TUPLE: windows-ce-io ; UNION: windows-io windows-nt-io windows-ce-io ; +M: windows-io library-roots ( -- seq ) + [ + windows , + ] { } make ; + +M: windows-io binary-roots ( -- seq ) + [ + windows , + ] { } make ; + M: windows-io destruct-handle CloseHandle drop ; M: windows-io destruct-socket closesocket drop ;