@@ -8,7 +8,7 @@ import middle::resolve;
8
8
import syntax:: visit;
9
9
import syntax:: codemap:: span;
10
10
import back:: x86;
11
- import util:: common;
11
+ import util :: { common, filesearch } ;
12
12
import std :: { vec, str, fs, io, option} ;
13
13
import std:: option:: { none, some} ;
14
14
import std:: map:: { hashmap, new_int_hash} ;
@@ -131,49 +131,41 @@ fn find_library_crate(sess: session::session, ident: ast::ident,
131
131
let nn = default_native_lib_naming ( sess, sess. get_opts ( ) . static ) ;
132
132
let x =
133
133
find_library_crate_aux ( nn, crate_name, metas,
134
- sess. filesearch ( ) . lib_search_paths ( ) ) ;
134
+ sess. filesearch ( ) ) ;
135
135
if x != none || sess. get_opts ( ) . static { ret x; }
136
136
let nn2 = default_native_lib_naming ( sess, true ) ;
137
137
ret find_library_crate_aux ( nn2, crate_name, metas,
138
- sess. filesearch ( ) . lib_search_paths ( ) ) ;
138
+ sess. filesearch ( ) ) ;
139
139
}
140
140
141
141
fn find_library_crate_aux ( nn : { prefix : str , suffix : str } , crate_name : str ,
142
142
metas : [ @ast:: meta_item ] ,
143
- library_search_paths : [ str ] ) ->
143
+ filesearch : filesearch :: filesearch ) ->
144
144
option:: t < { ident: str , data : @[ u8 ] } > {
145
145
let prefix: str = nn. prefix + crate_name;
146
146
let suffix: str = nn. suffix ;
147
- // FIXME: we could probably use a 'glob' function in std::fs but it will
148
- // be much easier to write once the unsafe module knows more about FFI
149
- // tricks. Currently the glob(3) interface is a bit more than we can
150
- // stomach from here, and writing a C++ wrapper is more work than just
151
- // manually filtering fs::list_dir here.
152
147
153
- for library_search_path: str in library_search_paths {
154
- log #fmt[ "searching %s" , library_search_path] ;
155
- for path: str in fs:: list_dir ( library_search_path) {
156
- log #fmt[ "searching %s" , path] ;
157
- let f: str = fs:: basename ( path) ;
158
- if !( str:: starts_with ( f, prefix) && str:: ends_with ( f, suffix) ) {
159
- log #fmt[ "skipping %s, doesn't look like %s*%s" , path, prefix,
160
- suffix] ;
161
- cont;
162
- }
148
+ ret filesearch:: search ( filesearch, { |path|
149
+ let f: str = fs:: basename ( path) ;
150
+ if !( str:: starts_with ( f, prefix) && str:: ends_with ( f, suffix) ) {
151
+ log #fmt[ "skipping %s, doesn't look like %s*%s" , path, prefix,
152
+ suffix] ;
153
+ option:: none
154
+ } else {
163
155
alt get_metadata_section ( path) {
164
156
option:: some ( cvec) {
165
157
if !metadata_matches ( cvec, metas) {
166
158
log #fmt[ "skipping %s, metadata doesn't match" , path] ;
167
- cont;
159
+ option:: none
160
+ } else {
161
+ log #fmt[ "found %s with matching metadata" , path] ;
162
+ option:: some ( { ident: path, data: cvec} )
168
163
}
169
- log #fmt[ "found %s with matching metadata" , path] ;
170
- ret some( { ident: path, data: cvec} ) ;
171
164
}
172
- _ { }
165
+ _ { option : : none }
173
166
}
174
167
}
175
- }
176
- ret none;
168
+ } ) ;
177
169
}
178
170
179
171
fn get_metadata_section ( filename : str ) -> option:: t < @[ u8 ] > {
0 commit comments