auto merge of #16243 : alexcrichton/rust/fix-utime-for-windows, r=brson
Apparently the units are in milliseconds, not in seconds!
This commit is contained in:
commit
fd02916f0e
@ -516,8 +516,8 @@ pub fn lstat(_p: &CString) -> IoResult<rtio::FileStat> {
|
||||
|
||||
pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
|
||||
let mut buf = libc::utimbuf {
|
||||
actime: (atime / 1000) as libc::time64_t,
|
||||
modtime: (mtime / 1000) as libc::time64_t,
|
||||
actime: atime as libc::time64_t,
|
||||
modtime: mtime as libc::time64_t,
|
||||
};
|
||||
let p = try!(to_utf16(p));
|
||||
super::mkerr_libc(unsafe {
|
||||
|
@ -1588,8 +1588,7 @@ mod test {
|
||||
"truncate didn't truncate");
|
||||
})
|
||||
|
||||
#[test]
|
||||
fn utime() {
|
||||
iotest!(fn utime() {
|
||||
let tmpdir = tmpdir();
|
||||
let path = tmpdir.join("a");
|
||||
check!(File::create(&path));
|
||||
@ -1597,17 +1596,16 @@ mod test {
|
||||
check!(change_file_times(&path, 1000, 2000));
|
||||
assert_eq!(check!(path.stat()).accessed, 1000);
|
||||
assert_eq!(check!(path.stat()).modified, 2000);
|
||||
}
|
||||
})
|
||||
|
||||
#[test]
|
||||
fn utime_noexist() {
|
||||
iotest!(fn utime_noexist() {
|
||||
let tmpdir = tmpdir();
|
||||
|
||||
match change_file_times(&tmpdir.join("a"), 100, 200) {
|
||||
Ok(..) => fail!(),
|
||||
Err(..) => {}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
iotest!(fn binary_file() {
|
||||
use rand::{StdRng, Rng};
|
||||
|
Loading…
x
Reference in New Issue
Block a user