< prev index next >

src/java.base/unix/native/libjava/UnixFileSystem_md.c

Print this page
rev 17196 : 8177809: File.lastModified() is losing milliseconds (always ends in 000)
Summary: Use higher precision time values where available.
Reviewed-by: XXX

*** 1,7 **** /* ! * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 227,237 **** jlong rv = 0; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { struct stat64 sb; if (stat64(path, &sb) == 0) { ! rv = 1000 * (jlong)sb.st_mtime; } } END_PLATFORM_STRING(env, path); return rv; } --- 227,243 ---- jlong rv = 0; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { struct stat64 sb; if (stat64(path, &sb) == 0) { ! #ifndef MACOSX ! rv = (jlong)sb.st_mtim.tv_sec * 1000; ! rv += (jlong)sb.st_mtim.tv_nsec / 1000000; ! #else ! rv = (jlong)sb.st_mtimespec.tv_sec * 1000; ! rv += (jlong)sb.st_mtimespec.tv_nsec / 1000000; ! #endif } } END_PLATFORM_STRING(env, path); return rv; }
*** 411,422 **** if (stat64(path, &sb) == 0) { struct timeval tv[2]; /* Preserve access time */ ! tv[0].tv_sec = sb.st_atime; ! tv[0].tv_usec = 0; /* Change last-modified time */ tv[1].tv_sec = time / 1000; tv[1].tv_usec = (time % 1000) * 1000; --- 417,433 ---- if (stat64(path, &sb) == 0) { struct timeval tv[2]; /* Preserve access time */ ! #ifndef MACOSX ! tv[0].tv_sec = sb.st_atim.tv_sec; ! tv[0].tv_usec = sb.st_atim.tv_nsec / 1000; ! #else ! tv[0].tv_sec = sb.st_atimespec.tv_sec; ! tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000; ! #endif /* Change last-modified time */ tv[1].tv_sec = time / 1000; tv[1].tv_usec = (time % 1000) * 1000;
< prev index next >