< prev index next >

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

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.fs;
  27 
  28 import java.nio.file.attribute.*;
  29 import java.util.concurrent.TimeUnit;
  30 import java.security.AccessController;
  31 import jdk.internal.misc.Unsafe;
  32 import sun.security.action.GetPropertyAction;
  33 
  34 import static sun.nio.fs.WindowsNativeDispatcher.*;
  35 import static sun.nio.fs.WindowsConstants.*;
  36 
  37 /**
  38  * Windows implementation of DosFileAttributes/BasicFileAttributes
  39  */
  40 
  41 class WindowsFileAttributes
  42     implements DosFileAttributes
  43 {
  44     private static final Unsafe unsafe = Unsafe.getUnsafe();
  45 
  46     /*
  47      * typedef struct _BY_HANDLE_FILE_INFORMATION {
  48      *     DWORD    dwFileAttributes;
  49      *     FILETIME ftCreationTime;
  50      *     FILETIME ftLastAccessTime;


  98      *   DWORD dwReserved1;
  99      *   TCHAR cFileName[MAX_PATH];
 100      *   TCHAR cAlternateFileName[14];
 101      * } WIN32_FIND_DATA;
 102      */
 103     private static final short SIZEOF_FIND_DATA = 592;
 104     private static final short OFFSETOF_FIND_DATA_ATTRIBUTES = 0;
 105     private static final short OFFSETOF_FIND_DATA_CREATETIME = 4;
 106     private static final short OFFSETOF_FIND_DATA_LASTACCESSTIME = 12;
 107     private static final short OFFSETOF_FIND_DATA_LASTWRITETIME = 20;
 108     private static final short OFFSETOF_FIND_DATA_SIZEHIGH = 28;
 109     private static final short OFFSETOF_FIND_DATA_SIZELOW = 32;
 110     private static final short OFFSETOF_FIND_DATA_RESERVED0 = 36;
 111 
 112     // used to adjust values between Windows and java epoch
 113     private static final long WINDOWS_EPOCH_IN_MICROSECONDS = -11644473600000000L;
 114 
 115     // indicates if accurate metadata is required (interesting on NTFS only)
 116     private static final boolean ensureAccurateMetadata;
 117     static {
 118         String propValue = AccessController.doPrivileged(
 119             new GetPropertyAction("sun.nio.fs.ensureAccurateMetadata", "false"));
 120         ensureAccurateMetadata = (propValue.length() == 0) ?
 121             true : Boolean.valueOf(propValue);
 122     }
 123 
 124     // attributes
 125     private final int fileAttrs;
 126     private final long creationTime;
 127     private final long lastAccessTime;
 128     private final long lastWriteTime;
 129     private final long size;
 130     private final int reparseTag;
 131 
 132     // additional attributes when using GetFileInformationByHandle
 133     private final int volSerialNumber;
 134     private final int fileIndexHigh;
 135     private final int fileIndexLow;
 136 
 137     /**
 138      * Convert 64-bit value representing the number of 100-nanosecond intervals
 139      * since January 1, 1601 to a FileTime.




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.fs;
  27 
  28 import java.nio.file.attribute.*;
  29 import java.util.concurrent.TimeUnit;

  30 import jdk.internal.misc.Unsafe;
  31 import sun.security.action.GetPropertyAction;
  32 
  33 import static sun.nio.fs.WindowsNativeDispatcher.*;
  34 import static sun.nio.fs.WindowsConstants.*;
  35 
  36 /**
  37  * Windows implementation of DosFileAttributes/BasicFileAttributes
  38  */
  39 
  40 class WindowsFileAttributes
  41     implements DosFileAttributes
  42 {
  43     private static final Unsafe unsafe = Unsafe.getUnsafe();
  44 
  45     /*
  46      * typedef struct _BY_HANDLE_FILE_INFORMATION {
  47      *     DWORD    dwFileAttributes;
  48      *     FILETIME ftCreationTime;
  49      *     FILETIME ftLastAccessTime;


  97      *   DWORD dwReserved1;
  98      *   TCHAR cFileName[MAX_PATH];
  99      *   TCHAR cAlternateFileName[14];
 100      * } WIN32_FIND_DATA;
 101      */
 102     private static final short SIZEOF_FIND_DATA = 592;
 103     private static final short OFFSETOF_FIND_DATA_ATTRIBUTES = 0;
 104     private static final short OFFSETOF_FIND_DATA_CREATETIME = 4;
 105     private static final short OFFSETOF_FIND_DATA_LASTACCESSTIME = 12;
 106     private static final short OFFSETOF_FIND_DATA_LASTWRITETIME = 20;
 107     private static final short OFFSETOF_FIND_DATA_SIZEHIGH = 28;
 108     private static final short OFFSETOF_FIND_DATA_SIZELOW = 32;
 109     private static final short OFFSETOF_FIND_DATA_RESERVED0 = 36;
 110 
 111     // used to adjust values between Windows and java epoch
 112     private static final long WINDOWS_EPOCH_IN_MICROSECONDS = -11644473600000000L;
 113 
 114     // indicates if accurate metadata is required (interesting on NTFS only)
 115     private static final boolean ensureAccurateMetadata;
 116     static {
 117         String propValue = GetPropertyAction
 118                 .getProperty("sun.nio.fs.ensureAccurateMetadata", "false");
 119         ensureAccurateMetadata = (propValue.length() == 0) ?
 120             true : Boolean.valueOf(propValue);
 121     }
 122 
 123     // attributes
 124     private final int fileAttrs;
 125     private final long creationTime;
 126     private final long lastAccessTime;
 127     private final long lastWriteTime;
 128     private final long size;
 129     private final int reparseTag;
 130 
 131     // additional attributes when using GetFileInformationByHandle
 132     private final int volSerialNumber;
 133     private final int fileIndexHigh;
 134     private final int fileIndexLow;
 135 
 136     /**
 137      * Convert 64-bit value representing the number of 100-nanosecond intervals
 138      * since January 1, 1601 to a FileTime.


< prev index next >