10
10
11
11
#![ deny( warnings) ]
12
12
13
- extern crate filetime;
14
-
15
13
use std:: fs:: File ;
16
14
use std:: path:: { Path , PathBuf } ;
17
15
use std:: process:: { Command , Stdio } ;
18
16
use std:: { fs, env} ;
19
-
20
- use filetime:: FileTime ;
17
+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
21
18
22
19
/// A helper macro to `unwrap` a result except also print out details like:
23
20
///
@@ -137,10 +134,8 @@ pub fn rerun_if_changed_anything_in_dir(dir: &Path) {
137
134
}
138
135
139
136
/// Returns the last-modified time for `path`, or zero if it doesn't exist.
140
- pub fn mtime ( path : & Path ) -> FileTime {
141
- fs:: metadata ( path) . map ( |f| {
142
- FileTime :: from_last_modification_time ( & f)
143
- } ) . unwrap_or ( FileTime :: zero ( ) )
137
+ pub fn mtime ( path : & Path ) -> SystemTime {
138
+ fs:: metadata ( path) . and_then ( |f| f. modified ( ) ) . unwrap_or ( UNIX_EPOCH )
144
139
}
145
140
146
141
/// Returns whether `dst` is up to date given that the file or files in `src`
@@ -157,9 +152,9 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool {
157
152
Err ( e) => panic ! ( "source {:?} failed to get metadata: {}" , src, e) ,
158
153
} ;
159
154
if meta. is_dir ( ) {
160
- dir_up_to_date ( src, & threshold)
155
+ dir_up_to_date ( src, threshold)
161
156
} else {
162
- FileTime :: from_last_modification_time ( & meta) <= threshold
157
+ meta. modified ( ) . unwrap_or ( UNIX_EPOCH ) <= threshold
163
158
}
164
159
}
165
160
@@ -226,13 +221,13 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<NativeLibBoiler
226
221
search_path)
227
222
}
228
223
229
- fn dir_up_to_date ( src : & Path , threshold : & FileTime ) -> bool {
224
+ fn dir_up_to_date ( src : & Path , threshold : SystemTime ) -> bool {
230
225
t ! ( fs:: read_dir( src) ) . map ( |e| t ! ( e) ) . all ( |e| {
231
226
let meta = t ! ( e. metadata( ) ) ;
232
227
if meta. is_dir ( ) {
233
228
dir_up_to_date ( & e. path ( ) , threshold)
234
229
} else {
235
- FileTime :: from_last_modification_time ( & meta) < * threshold
230
+ meta. modified ( ) . unwrap_or ( UNIX_EPOCH ) < threshold
236
231
}
237
232
} )
238
233
}
0 commit comments