Skip to content

Commit

Permalink
native: Fix utime() for windows
Browse files Browse the repository at this point in the history
Apparently the units are in milliseconds, not in seconds!
  • Loading branch information
alexcrichton committed Aug 2, 2014
1 parent 87bc22f commit 2677e5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/libnative/io/file_win32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 4 additions & 6 deletions src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1588,26 +1588,24 @@ mod test {
"truncate didn't truncate");
})

#[test]
fn utime() {
iotest!(fn utime() {
let tmpdir = tmpdir();
let path = tmpdir.join("a");
check!(File::create(&path));

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};
Expand Down

5 comments on commit 2677e5f

@bors
Copy link
Contributor

@bors bors commented on 2677e5f Aug 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at alexcrichton@2677e5f

@bors
Copy link
Contributor

@bors bors commented on 2677e5f Aug 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/fix-utime-for-windows = 2677e5f into auto

@bors
Copy link
Contributor

@bors bors commented on 2677e5f Aug 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/fix-utime-for-windows = 2677e5f merged ok, testing candidate = fd02916

@bors
Copy link
Contributor

@bors bors commented on 2677e5f Aug 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = fd02916

Please sign in to comment.