Skip to content

Commit fd02916

Browse files
committed
auto merge of rust-lang#16243 : alexcrichton/rust/fix-utime-for-windows, r=brson
Apparently the units are in milliseconds, not in seconds!
2 parents cbdae97 + 2677e5f commit fd02916

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/libnative/io/file_win32.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ pub fn lstat(_p: &CString) -> IoResult<rtio::FileStat> {
516516

517517
pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
518518
let mut buf = libc::utimbuf {
519-
actime: (atime / 1000) as libc::time64_t,
520-
modtime: (mtime / 1000) as libc::time64_t,
519+
actime: atime as libc::time64_t,
520+
modtime: mtime as libc::time64_t,
521521
};
522522
let p = try!(to_utf16(p));
523523
super::mkerr_libc(unsafe {

src/libstd/io/fs.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1588,26 +1588,24 @@ mod test {
15881588
"truncate didn't truncate");
15891589
})
15901590

1591-
#[test]
1592-
fn utime() {
1591+
iotest!(fn utime() {
15931592
let tmpdir = tmpdir();
15941593
let path = tmpdir.join("a");
15951594
check!(File::create(&path));
15961595

15971596
check!(change_file_times(&path, 1000, 2000));
15981597
assert_eq!(check!(path.stat()).accessed, 1000);
15991598
assert_eq!(check!(path.stat()).modified, 2000);
1600-
}
1599+
})
16011600

1602-
#[test]
1603-
fn utime_noexist() {
1601+
iotest!(fn utime_noexist() {
16041602
let tmpdir = tmpdir();
16051603

16061604
match change_file_times(&tmpdir.join("a"), 100, 200) {
16071605
Ok(..) => fail!(),
16081606
Err(..) => {}
16091607
}
1610-
}
1608+
})
16111609

16121610
iotest!(fn binary_file() {
16131611
use rand::{StdRng, Rng};

0 commit comments

Comments
 (0)