1010
1111#![ deny( warnings) ]
1212
13- extern crate filetime;
14-
1513use std:: fs:: File ;
1614use std:: path:: { Path , PathBuf } ;
1715use std:: process:: { Command , Stdio } ;
1816use std:: { fs, env} ;
19-
20- use filetime:: FileTime ;
17+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
2118
2219/// A helper macro to `unwrap` a result except also print out details like:
2320///
@@ -137,10 +134,8 @@ pub fn rerun_if_changed_anything_in_dir(dir: &Path) {
137134}
138135
139136/// 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 )
144139}
145140
146141/// 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 {
157152 Err ( e) => panic ! ( "source {:?} failed to get metadata: {}" , src, e) ,
158153 } ;
159154 if meta. is_dir ( ) {
160- dir_up_to_date ( src, & threshold)
155+ dir_up_to_date ( src, threshold)
161156 } else {
162- FileTime :: from_last_modification_time ( & meta) <= threshold
157+ meta. modified ( ) . unwrap_or ( UNIX_EPOCH ) <= threshold
163158 }
164159}
165160
@@ -226,13 +221,13 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<NativeLibBoiler
226221 search_path)
227222}
228223
229- fn dir_up_to_date ( src : & Path , threshold : & FileTime ) -> bool {
224+ fn dir_up_to_date ( src : & Path , threshold : SystemTime ) -> bool {
230225 t ! ( fs:: read_dir( src) ) . map ( |e| t ! ( e) ) . all ( |e| {
231226 let meta = t ! ( e. metadata( ) ) ;
232227 if meta. is_dir ( ) {
233228 dir_up_to_date ( & e. path ( ) , threshold)
234229 } else {
235- FileTime :: from_last_modification_time ( & meta) < * threshold
230+ meta. modified ( ) . unwrap_or ( UNIX_EPOCH ) < threshold
236231 }
237232 } )
238233}
0 commit comments