]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/libraries/finder/windows/windows.factor
alien.libraries.finder.windows: more like MSDN search order.
[factor.git] / basis / alien / libraries / finder / windows / windows.factor
1 ! Copyright (C) 2013 Björn Lindqvist, John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: alien.libraries.finder arrays combinators.short-circuit
5 environment io.files io.files.info io.pathnames kernel sequences
6 splitting system system-info.windows ;
7
8 IN: alien.libraries.finder.windows
9
10 <PRIVATE
11
12 : search-paths ( -- seq )
13     "resource:" system-directory windows-directory 3array
14     "PATH" os-env [ ";" split ] [ f ] if* append ;
15
16 : candidate-paths ( name -- seq )
17     search-paths over ".dll" tail? [
18         [ prepend-path ] with map
19     ] [
20         [
21             [ prepend-path ]
22             [ [ ".dll" append ] [ prepend-path ] bi* ] 2bi
23             2array
24         ] with map concat
25     ] if ;
26
27 PRIVATE>
28
29 M: windows find-library
30     candidate-paths [
31         { [ exists? ] [ file-info regular-file? ] } 1&&
32     ] map-find nip ;