author | bpb |
Wed, 25 Sep 2019 11:44:52 -0700 | |
changeset 58341 | 21a03fa2f6b6 |
parent 53018 | 8bf9268df0e2 |
permissions | -rw-r--r-- |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1 |
/* |
58341
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
2 |
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
4 |
* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
10 |
* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
15 |
* accompanied this code). |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
16 |
* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
20 |
* |
5506 | 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. |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
24 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
25 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
26 |
package sun.nio.fs; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
27 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
28 |
import java.nio.file.attribute.*; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
29 |
import java.util.concurrent.TimeUnit; |
33674
566777f73c32
8140606: Update library code to use internal Unsafe
chegar
parents:
25859
diff
changeset
|
30 |
import jdk.internal.misc.Unsafe; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
31 |
import sun.security.action.GetPropertyAction; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
32 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
33 |
import static sun.nio.fs.WindowsNativeDispatcher.*; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
34 |
import static sun.nio.fs.WindowsConstants.*; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
35 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
36 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
37 |
* Windows implementation of DosFileAttributes/BasicFileAttributes |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
38 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
39 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
40 |
class WindowsFileAttributes |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
41 |
implements DosFileAttributes |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
42 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
43 |
private static final Unsafe unsafe = Unsafe.getUnsafe(); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
44 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
45 |
/* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
46 |
* typedef struct _BY_HANDLE_FILE_INFORMATION { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
47 |
* DWORD dwFileAttributes; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
48 |
* FILETIME ftCreationTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
49 |
* FILETIME ftLastAccessTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
50 |
* FILETIME ftLastWriteTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
51 |
* DWORD dwVolumeSerialNumber; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
52 |
* DWORD nFileSizeHigh; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
53 |
* DWORD nFileSizeLow; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
54 |
* DWORD nNumberOfLinks; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
55 |
* DWORD nFileIndexHigh; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
56 |
* DWORD nFileIndexLow; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
57 |
* } BY_HANDLE_FILE_INFORMATION; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
58 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
59 |
private static final short SIZEOF_FILE_INFORMATION = 52; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
60 |
private static final short OFFSETOF_FILE_INFORMATION_ATTRIBUTES = 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
61 |
private static final short OFFSETOF_FILE_INFORMATION_CREATETIME = 4; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
62 |
private static final short OFFSETOF_FILE_INFORMATION_LASTACCESSTIME = 12; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
63 |
private static final short OFFSETOF_FILE_INFORMATION_LASTWRITETIME = 20; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
64 |
private static final short OFFSETOF_FILE_INFORMATION_VOLSERIALNUM = 28; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
65 |
private static final short OFFSETOF_FILE_INFORMATION_SIZEHIGH = 32; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
66 |
private static final short OFFSETOF_FILE_INFORMATION_SIZELOW = 36; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
67 |
private static final short OFFSETOF_FILE_INFORMATION_INDEXHIGH = 44; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
68 |
private static final short OFFSETOF_FILE_INFORMATION_INDEXLOW = 48; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
69 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
70 |
/* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
71 |
* typedef struct _WIN32_FILE_ATTRIBUTE_DATA { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
72 |
* DWORD dwFileAttributes; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
73 |
* FILETIME ftCreationTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
74 |
* FILETIME ftLastAccessTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
75 |
* FILETIME ftLastWriteTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
76 |
* DWORD nFileSizeHigh; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
77 |
* DWORD nFileSizeLow; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
78 |
* } WIN32_FILE_ATTRIBUTE_DATA; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
79 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
80 |
private static final short SIZEOF_FILE_ATTRIBUTE_DATA = 36; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
81 |
private static final short OFFSETOF_FILE_ATTRIBUTE_DATA_ATTRIBUTES = 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
82 |
private static final short OFFSETOF_FILE_ATTRIBUTE_DATA_CREATETIME = 4; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
83 |
private static final short OFFSETOF_FILE_ATTRIBUTE_DATA_LASTACCESSTIME = 12; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
84 |
private static final short OFFSETOF_FILE_ATTRIBUTE_DATA_LASTWRITETIME = 20; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
85 |
private static final short OFFSETOF_FILE_ATTRIBUTE_DATA_SIZEHIGH = 28; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
86 |
private static final short OFFSETOF_FILE_ATTRIBUTE_DATA_SIZELOW = 32; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
87 |
|
2071
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
88 |
/** |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
89 |
* typedef struct _WIN32_FIND_DATA { |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
90 |
* DWORD dwFileAttributes; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
91 |
* FILETIME ftCreationTime; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
92 |
* FILETIME ftLastAccessTime; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
93 |
* FILETIME ftLastWriteTime; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
94 |
* DWORD nFileSizeHigh; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
95 |
* DWORD nFileSizeLow; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
96 |
* DWORD dwReserved0; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
97 |
* DWORD dwReserved1; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
98 |
* TCHAR cFileName[MAX_PATH]; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
99 |
* TCHAR cAlternateFileName[14]; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
100 |
* } WIN32_FIND_DATA; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
101 |
*/ |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
102 |
private static final short SIZEOF_FIND_DATA = 592; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
103 |
private static final short OFFSETOF_FIND_DATA_ATTRIBUTES = 0; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
104 |
private static final short OFFSETOF_FIND_DATA_CREATETIME = 4; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
105 |
private static final short OFFSETOF_FIND_DATA_LASTACCESSTIME = 12; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
106 |
private static final short OFFSETOF_FIND_DATA_LASTWRITETIME = 20; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
107 |
private static final short OFFSETOF_FIND_DATA_SIZEHIGH = 28; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
108 |
private static final short OFFSETOF_FIND_DATA_SIZELOW = 32; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
109 |
private static final short OFFSETOF_FIND_DATA_RESERVED0 = 36; |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
110 |
|
58341
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
111 |
// used to adjust values between Windows and java epochs |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
112 |
private static final long WINDOWS_EPOCH_IN_MICROS = -11644473600000000L; |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
113 |
private static final long WINDOWS_EPOCH_IN_100NS = -116444736000000000L; |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
114 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
115 |
// indicates if accurate metadata is required (interesting on NTFS only) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
116 |
private static final boolean ensureAccurateMetadata; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
117 |
static { |
37781
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
118 |
String propValue = GetPropertyAction.privilegedGetProperty( |
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
119 |
"sun.nio.fs.ensureAccurateMetadata", "false"); |
53018
8bf9268df0e2
8215281: Use String.isEmpty() when applicable in java.base
redestad
parents:
47216
diff
changeset
|
120 |
ensureAccurateMetadata = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
121 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
122 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
123 |
// attributes |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
124 |
private final int fileAttrs; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
125 |
private final long creationTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
126 |
private final long lastAccessTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
127 |
private final long lastWriteTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
128 |
private final long size; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
129 |
private final int reparseTag; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
130 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
131 |
// additional attributes when using GetFileInformationByHandle |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
132 |
private final int volSerialNumber; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
133 |
private final int fileIndexHigh; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
134 |
private final int fileIndexLow; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
135 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
136 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
137 |
* Convert 64-bit value representing the number of 100-nanosecond intervals |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
138 |
* since January 1, 1601 to a FileTime. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
139 |
*/ |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
140 |
static FileTime toFileTime(long time) { |
58341
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
141 |
try { |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
142 |
long adjusted = Math.addExact(time, WINDOWS_EPOCH_IN_100NS); |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
143 |
long nanos = Math.multiplyExact(adjusted, 100L); |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
144 |
return FileTime.from(nanos, TimeUnit.NANOSECONDS); |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
145 |
} catch (ArithmeticException e) { |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
146 |
long micros = Math.addExact(time/10L, WINDOWS_EPOCH_IN_MICROS); |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
147 |
return FileTime.from(micros, TimeUnit.MICROSECONDS); |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
148 |
} |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
149 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
150 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
151 |
/** |
58341
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
152 |
* Convert FileTime to 64-bit value representing the number of |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
153 |
* 100-nanosecond intervals since January 1, 1601. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
154 |
*/ |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
155 |
static long toWindowsTime(FileTime time) { |
58341
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
156 |
long adjusted = time.to(TimeUnit.NANOSECONDS)/100L; |
21a03fa2f6b6
8231174: (fs) FileTime should have 100ns resolution (win)
bpb
parents:
53018
diff
changeset
|
157 |
return adjusted - WINDOWS_EPOCH_IN_100NS; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
158 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
159 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
160 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
161 |
* Initialize a new instance of this class |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
162 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
163 |
private WindowsFileAttributes(int fileAttrs, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
164 |
long creationTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
165 |
long lastAccessTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
166 |
long lastWriteTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
167 |
long size, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
168 |
int reparseTag, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
169 |
int volSerialNumber, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
170 |
int fileIndexHigh, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
171 |
int fileIndexLow) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
172 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
173 |
this.fileAttrs = fileAttrs; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
174 |
this.creationTime = creationTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
175 |
this.lastAccessTime = lastAccessTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
176 |
this.lastWriteTime = lastWriteTime; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
177 |
this.size = size; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
178 |
this.reparseTag = reparseTag; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
179 |
this.volSerialNumber = volSerialNumber; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
180 |
this.fileIndexHigh = fileIndexHigh; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
181 |
this.fileIndexLow = fileIndexLow; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
182 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
183 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
184 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
185 |
* Create a WindowsFileAttributes from a BY_HANDLE_FILE_INFORMATION structure |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
186 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
187 |
private static WindowsFileAttributes fromFileInformation(long address, int reparseTag) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
188 |
int fileAttrs = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_ATTRIBUTES); |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
189 |
long creationTime = unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_CREATETIME); |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
190 |
long lastAccessTime = unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_LASTACCESSTIME); |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
191 |
long lastWriteTime = unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_LASTWRITETIME); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
192 |
long size = ((long)(unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_SIZEHIGH)) << 32) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
193 |
+ (unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_SIZELOW) & 0xFFFFFFFFL); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
194 |
int volSerialNumber = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_VOLSERIALNUM); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
195 |
int fileIndexHigh = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_INDEXHIGH); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
196 |
int fileIndexLow = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_INDEXLOW); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
197 |
return new WindowsFileAttributes(fileAttrs, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
198 |
creationTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
199 |
lastAccessTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
200 |
lastWriteTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
201 |
size, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
202 |
reparseTag, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
203 |
volSerialNumber, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
204 |
fileIndexHigh, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
205 |
fileIndexLow); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
206 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
207 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
208 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
209 |
* Create a WindowsFileAttributes from a WIN32_FILE_ATTRIBUTE_DATA structure |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
210 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
211 |
private static WindowsFileAttributes fromFileAttributeData(long address, int reparseTag) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
212 |
int fileAttrs = unsafe.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_ATTRIBUTES); |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
213 |
long creationTime = unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_CREATETIME); |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
214 |
long lastAccessTime = unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_LASTACCESSTIME); |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
215 |
long lastWriteTime = unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_LASTWRITETIME); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
216 |
long size = ((long)(unsafe.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_SIZEHIGH)) << 32) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
217 |
+ (unsafe.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_SIZELOW) & 0xFFFFFFFFL); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
218 |
return new WindowsFileAttributes(fileAttrs, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
219 |
creationTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
220 |
lastAccessTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
221 |
lastWriteTime, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
222 |
size, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
223 |
reparseTag, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
224 |
0, // volSerialNumber |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
225 |
0, // fileIndexHigh |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
226 |
0); // fileIndexLow |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
227 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
228 |
|
2071
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
229 |
|
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
230 |
/** |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
231 |
* Allocates a native buffer for a WIN32_FIND_DATA structure |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
232 |
*/ |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
233 |
static NativeBuffer getBufferForFindData() { |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
234 |
return NativeBuffers.getNativeBuffer(SIZEOF_FIND_DATA); |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
235 |
} |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
236 |
|
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
237 |
/** |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
238 |
* Create a WindowsFileAttributes from a WIN32_FIND_DATA structure |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
239 |
*/ |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
240 |
static WindowsFileAttributes fromFindData(long address) { |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
241 |
int fileAttrs = unsafe.getInt(address + OFFSETOF_FIND_DATA_ATTRIBUTES); |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
242 |
long creationTime = unsafe.getLong(address + OFFSETOF_FIND_DATA_CREATETIME); |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
243 |
long lastAccessTime = unsafe.getLong(address + OFFSETOF_FIND_DATA_LASTACCESSTIME); |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
244 |
long lastWriteTime = unsafe.getLong(address + OFFSETOF_FIND_DATA_LASTWRITETIME); |
2071
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
245 |
long size = ((long)(unsafe.getInt(address + OFFSETOF_FIND_DATA_SIZEHIGH)) << 32) |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
246 |
+ (unsafe.getInt(address + OFFSETOF_FIND_DATA_SIZELOW) & 0xFFFFFFFFL); |
3628
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
247 |
int reparseTag = isReparsePoint(fileAttrs) ? |
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
248 |
unsafe.getInt(address + OFFSETOF_FIND_DATA_RESERVED0) : 0; |
2071
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
249 |
return new WindowsFileAttributes(fileAttrs, |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
250 |
creationTime, |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
251 |
lastAccessTime, |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
252 |
lastWriteTime, |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
253 |
size, |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
254 |
reparseTag, |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
255 |
0, // volSerialNumber |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
256 |
0, // fileIndexHigh |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
257 |
0); // fileIndexLow |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
258 |
} |
5e6af6d106cb
6808647: (file) Paths.get("C:").newDirectoryStream() iterates over Path elements with additional slash [win]
alanb
parents:
2057
diff
changeset
|
259 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
260 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
261 |
* Reads the attributes of an open file |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
262 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
263 |
static WindowsFileAttributes readAttributes(long handle) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
264 |
throws WindowsException |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
265 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
266 |
NativeBuffer buffer = NativeBuffers |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
267 |
.getNativeBuffer(SIZEOF_FILE_INFORMATION); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
268 |
try { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
269 |
long address = buffer.address(); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
270 |
GetFileInformationByHandle(handle, address); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
271 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
272 |
// if file is a reparse point then read the tag |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
273 |
int reparseTag = 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
274 |
int fileAttrs = unsafe |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
275 |
.getInt(address + OFFSETOF_FILE_INFORMATION_ATTRIBUTES); |
3628
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
276 |
if (isReparsePoint(fileAttrs)) { |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
277 |
int size = MAXIMUM_REPARSE_DATA_BUFFER_SIZE; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
278 |
NativeBuffer reparseBuffer = NativeBuffers.getNativeBuffer(size); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
279 |
try { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
280 |
DeviceIoControlGetReparsePoint(handle, reparseBuffer.address(), size); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
281 |
reparseTag = (int)unsafe.getLong(reparseBuffer.address()); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
282 |
} finally { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
283 |
reparseBuffer.release(); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
284 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
285 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
286 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
287 |
return fromFileInformation(address, reparseTag); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
288 |
} finally { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
289 |
buffer.release(); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
290 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
291 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
292 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
293 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
294 |
* Returns attributes of given file. |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
295 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
296 |
static WindowsFileAttributes get(WindowsPath path, boolean followLinks) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
297 |
throws WindowsException |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
298 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
299 |
if (!ensureAccurateMetadata) { |
3423
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
300 |
WindowsException firstException = null; |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
301 |
|
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
302 |
// GetFileAttributesEx is the fastest way to read the attributes |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
303 |
NativeBuffer buffer = |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
304 |
NativeBuffers.getNativeBuffer(SIZEOF_FILE_ATTRIBUTE_DATA); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
305 |
try { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
306 |
long address = buffer.address(); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
307 |
GetFileAttributesEx(path.getPathForWin32Calls(), address); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
308 |
// if reparse point then file may be a sym link; otherwise |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
309 |
// just return the attributes |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
310 |
int fileAttrs = unsafe |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
311 |
.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_ATTRIBUTES); |
3628
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
312 |
if (!isReparsePoint(fileAttrs)) |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
313 |
return fromFileAttributeData(address, 0); |
3423
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
314 |
} catch (WindowsException x) { |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
315 |
if (x.lastError() != ERROR_SHARING_VIOLATION) |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
316 |
throw x; |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
317 |
firstException = x; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
318 |
} finally { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
319 |
buffer.release(); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
320 |
} |
3423
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
321 |
|
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
322 |
// For sharing violations, fallback to FindFirstFile if the file |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
323 |
// is not a root directory. |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
324 |
if (firstException != null) { |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
325 |
String search = path.getPathForWin32Calls(); |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
326 |
char last = search.charAt(search.length() -1); |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
327 |
if (last == ':' || last == '\\') |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
328 |
throw firstException; |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
329 |
buffer = getBufferForFindData(); |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
330 |
try { |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
331 |
long handle = FindFirstFile(search, buffer.address()); |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
332 |
FindClose(handle); |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
333 |
WindowsFileAttributes attrs = fromFindData(buffer.address()); |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
334 |
// FindFirstFile does not follow sym links. Even if |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
335 |
// followLinks is false, there isn't sufficient information |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
336 |
// in the WIN32_FIND_DATA structure to know if the reparse |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
337 |
// point is a sym link. |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
338 |
if (attrs.isReparsePoint()) |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
339 |
throw firstException; |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
340 |
return attrs; |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
341 |
} catch (WindowsException ignore) { |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
342 |
throw firstException; |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
343 |
} finally { |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
344 |
buffer.release(); |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
345 |
} |
3dd3615c1748
6867101: Path.checkAccess fails with sharing violation on special files such as pagefile.sys
alanb
parents:
3065
diff
changeset
|
346 |
} |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
347 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
348 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
349 |
// file is reparse point so need to open file to get attributes |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
350 |
long handle = path.openForReadAttributeAccess(followLinks); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
351 |
try { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
352 |
return readAttributes(handle); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
353 |
} finally { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
354 |
CloseHandle(handle); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
355 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
356 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
357 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
358 |
/** |
3628
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
359 |
* Returns true if the attributes are of the same file - both files must |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
360 |
* be open. |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
361 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
362 |
static boolean isSameFile(WindowsFileAttributes attrs1, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
363 |
WindowsFileAttributes attrs2) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
364 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
365 |
// volume serial number and file index must be the same |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
366 |
return (attrs1.volSerialNumber == attrs2.volSerialNumber) && |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
367 |
(attrs1.fileIndexHigh == attrs2.fileIndexHigh) && |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
368 |
(attrs1.fileIndexLow == attrs2.fileIndexLow); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
369 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
370 |
|
3628
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
371 |
/** |
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
372 |
* Returns true if the attributes are of a file with a reparse point. |
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
373 |
*/ |
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
374 |
static boolean isReparsePoint(int attributes) { |
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
375 |
return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; |
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
376 |
} |
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
377 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
378 |
// package-private |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
379 |
int attributes() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
380 |
return fileAttrs; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
381 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
382 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
383 |
int volSerialNumber() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
384 |
return volSerialNumber; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
385 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
386 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
387 |
int fileIndexHigh() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
388 |
return fileIndexHigh; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
389 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
390 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
391 |
int fileIndexLow() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
392 |
return fileIndexLow; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
393 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
394 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
395 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
396 |
public long size() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
397 |
return size; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
398 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
399 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
400 |
@Override |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
401 |
public FileTime lastModifiedTime() { |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
402 |
return toFileTime(lastWriteTime); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
403 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
404 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
405 |
@Override |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
406 |
public FileTime lastAccessTime() { |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
407 |
return toFileTime(lastAccessTime); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
408 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
409 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
410 |
@Override |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
411 |
public FileTime creationTime() { |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2071
diff
changeset
|
412 |
return toFileTime(creationTime); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
413 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
414 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
415 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
416 |
public Object fileKey() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
417 |
return null; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
418 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
419 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
420 |
// package private |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
421 |
boolean isReparsePoint() { |
3628
2768d95a0e7d
6870926: (file) Path.toRealPath performance can be improved (win)
alanb
parents:
3423
diff
changeset
|
422 |
return isReparsePoint(fileAttrs); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
423 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
424 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
425 |
boolean isDirectoryLink() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
426 |
return isSymbolicLink() && ((fileAttrs & FILE_ATTRIBUTE_DIRECTORY) != 0); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
427 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
428 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
429 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
430 |
public boolean isSymbolicLink() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
431 |
return reparseTag == IO_REPARSE_TAG_SYMLINK; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
432 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
433 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
434 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
435 |
public boolean isDirectory() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
436 |
// ignore FILE_ATTRIBUTE_DIRECTORY attribute if file is a sym link |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
437 |
if (isSymbolicLink()) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
438 |
return false; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
439 |
return ((fileAttrs & FILE_ATTRIBUTE_DIRECTORY) != 0); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
440 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
441 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
442 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
443 |
public boolean isOther() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
444 |
if (isSymbolicLink()) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
445 |
return false; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
446 |
// return true if device or reparse point |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
447 |
return ((fileAttrs & (FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT)) != 0); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
448 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
449 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
450 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
451 |
public boolean isRegularFile() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
452 |
return !isSymbolicLink() && !isDirectory() && !isOther(); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
453 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
454 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
455 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
456 |
public boolean isReadOnly() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
457 |
return (fileAttrs & FILE_ATTRIBUTE_READONLY) != 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
458 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
459 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
460 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
461 |
public boolean isHidden() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
462 |
return (fileAttrs & FILE_ATTRIBUTE_HIDDEN) != 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
463 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
464 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
465 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
466 |
public boolean isArchive() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
467 |
return (fileAttrs & FILE_ATTRIBUTE_ARCHIVE) != 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
468 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
469 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
470 |
@Override |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
471 |
public boolean isSystem() { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
472 |
return (fileAttrs & FILE_ATTRIBUTE_SYSTEM) != 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
473 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
474 |
} |