< prev index next >

src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2008, 2012, 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) 2008, 2019, 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
*** 106,117 **** private static final short OFFSETOF_FIND_DATA_LASTWRITETIME = 20; private static final short OFFSETOF_FIND_DATA_SIZEHIGH = 28; private static final short OFFSETOF_FIND_DATA_SIZELOW = 32; private static final short OFFSETOF_FIND_DATA_RESERVED0 = 36; ! // used to adjust values between Windows and java epoch ! private static final long WINDOWS_EPOCH_IN_MICROSECONDS = -11644473600000000L; // indicates if accurate metadata is required (interesting on NTFS only) private static final boolean ensureAccurateMetadata; static { String propValue = GetPropertyAction.privilegedGetProperty( --- 106,118 ---- private static final short OFFSETOF_FIND_DATA_LASTWRITETIME = 20; private static final short OFFSETOF_FIND_DATA_SIZEHIGH = 28; private static final short OFFSETOF_FIND_DATA_SIZELOW = 32; private static final short OFFSETOF_FIND_DATA_RESERVED0 = 36; ! // used to adjust values between Windows and java epochs ! private static final long WINDOWS_EPOCH_IN_MICROS = -11644473600000000L; ! private static final long WINDOWS_EPOCH_IN_100NS = -116444736000000000L; // indicates if accurate metadata is required (interesting on NTFS only) private static final boolean ensureAccurateMetadata; static { String propValue = GetPropertyAction.privilegedGetProperty(
*** 135,162 **** /** * Convert 64-bit value representing the number of 100-nanosecond intervals * since January 1, 1601 to a FileTime. */ static FileTime toFileTime(long time) { ! // 100ns -> us ! time /= 10L; ! // adjust to java epoch ! time += WINDOWS_EPOCH_IN_MICROSECONDS; ! return FileTime.from(time, TimeUnit.MICROSECONDS); } /** ! * Convert FileTime to 64-bit value representing the number of 100-nanosecond ! * intervals since January 1, 1601. */ static long toWindowsTime(FileTime time) { ! long value = time.to(TimeUnit.MICROSECONDS); ! // adjust to Windows epoch+= 11644473600000000L; ! value -= WINDOWS_EPOCH_IN_MICROSECONDS; ! // us -> 100ns ! value *= 10L; ! return value; } /** * Initialize a new instance of this class */ --- 136,162 ---- /** * Convert 64-bit value representing the number of 100-nanosecond intervals * since January 1, 1601 to a FileTime. */ static FileTime toFileTime(long time) { ! try { ! long adjusted = Math.addExact(time, WINDOWS_EPOCH_IN_100NS); ! long nanos = Math.multiplyExact(adjusted, 100L); ! return FileTime.from(nanos, TimeUnit.NANOSECONDS); ! } catch (ArithmeticException e) { ! long micros = Math.addExact(time/10L, WINDOWS_EPOCH_IN_MICROS); ! return FileTime.from(micros, TimeUnit.MICROSECONDS); ! } } /** ! * Convert FileTime to 64-bit value representing the number of ! * 100-nanosecond intervals since January 1, 1601. */ static long toWindowsTime(FileTime time) { ! long adjusted = time.to(TimeUnit.NANOSECONDS)/100L; ! return adjusted - WINDOWS_EPOCH_IN_100NS; } /** * Initialize a new instance of this class */
< prev index next >