8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 jdk.internal.misc.Blocker;
29 import jdk.internal.misc.Unsafe;
30
31 import static sun.nio.fs.WindowsConstants.*;
32
33 /**
34 * Win32 and library calls.
35 */
36
37 class WindowsNativeDispatcher {
38 private WindowsNativeDispatcher() { }
39
40 /**
41 * HANDLE CreateEvent(
42 * LPSECURITY_ATTRIBUTES lpEventAttributes,
43 * BOOL bManualReset,
44 * BOOL bInitialState,
45 * PCTSTR lpName
46 * );
47 */
48 static native long CreateEvent(boolean bManualReset, boolean bInitialState)
51 /**
52 * HANDLE CreateFile(
53 * LPCTSTR lpFileName,
54 * DWORD dwDesiredAccess,
55 * DWORD dwShareMode,
56 * LPSECURITY_ATTRIBUTES lpSecurityAttributes,
57 * DWORD dwCreationDisposition,
58 * DWORD dwFlagsAndAttributes,
59 * HANDLE hTemplateFile
60 * )
61 */
62 static long CreateFile(String path,
63 int dwDesiredAccess,
64 int dwShareMode,
65 long lpSecurityAttributes,
66 int dwCreationDisposition,
67 int dwFlagsAndAttributes)
68 throws WindowsException
69 {
70 try (NativeBuffer buffer = asNativeBuffer(path)) {
71 long comp = Blocker.begin();
72 try {
73 return CreateFile0(buffer.address(),
74 dwDesiredAccess,
75 dwShareMode,
76 lpSecurityAttributes,
77 dwCreationDisposition,
78 dwFlagsAndAttributes);
79 } finally {
80 Blocker.end(comp);
81 }
82 }
83 }
84 static long CreateFile(String path,
85 int dwDesiredAccess,
86 int dwShareMode,
87 int dwCreationDisposition,
88 int dwFlagsAndAttributes)
89 throws WindowsException
90 {
91 return CreateFile(path, dwDesiredAccess, dwShareMode, 0L,
92 dwCreationDisposition, dwFlagsAndAttributes);
93 }
94 private static native long CreateFile0(long lpFileName,
95 int dwDesiredAccess,
96 int dwShareMode,
97 long lpSecurityAttributes,
98 int dwCreationDisposition,
99 int dwFlagsAndAttributes)
100 throws WindowsException;
101
102 /**
103 * CloseHandle(
104 * HANDLE hObject
105 * )
106 */
107 static native void CloseHandle(long handle);
108
109 /**
110 * DeleteFile(
111 * LPCTSTR lpFileName
112 * )
113 */
114 static void DeleteFile(String path) throws WindowsException {
115 try (NativeBuffer buffer = asNativeBuffer(path)) {
116 long comp = Blocker.begin();
117 try {
118 DeleteFile0(buffer.address());
119 } finally {
120 Blocker.end(comp);
121 }
122 }
123 }
124 private static native void DeleteFile0(long lpFileName)
125 throws WindowsException;
126
127 /**
128 * CreateDirectory(
129 * LPCTSTR lpPathName,
130 * LPSECURITY_ATTRIBUTES lpSecurityAttributes
131 * )
132 */
133 static void CreateDirectory(String path, long lpSecurityAttributes) throws WindowsException {
134 try (NativeBuffer buffer = asNativeBuffer(path)) {
135 long comp = Blocker.begin();
136 try {
137 CreateDirectory0(buffer.address(), lpSecurityAttributes);
138 } finally {
139 Blocker.end(comp);
140 }
141 }
142 }
143 private static native void CreateDirectory0(long lpFileName, long lpSecurityAttributes)
144 throws WindowsException;
145
146 /**
147 * RemoveDirectory(
148 * LPCTSTR lpPathName
149 * )
150 */
151 static void RemoveDirectory(String path) throws WindowsException {
152 try (NativeBuffer buffer = asNativeBuffer(path)) {
153 long comp = Blocker.begin();
154 try {
155 RemoveDirectory0(buffer.address());
156 } finally {
157 Blocker.end(comp);
158 }
159 }
160 }
161 private static native void RemoveDirectory0(long lpFileName)
162 throws WindowsException;
163
164 /**
165 * Marks a file as a sparse file.
166 *
167 * DeviceIoControl(
168 * FSCTL_SET_SPARSE
169 * )
170 */
171 static native void DeviceIoControlSetSparse(long handle)
172 throws WindowsException;
173
174 /**
175 * Retrieves the reparse point data associated with the file or directory.
176 *
177 * DeviceIoControl(
178 * FSCTL_GET_REPARSE_POINT
183
184 /**
185 * Retrieves the size of the specified file.
186 *
187 * BOOL GetFileSizeEx(
188 * HANDLE hFile,
189 * PLARGE_INTEGER lpFileSize
190 * )
191 */
192 static native long GetFileSizeEx(long handle) throws WindowsException;
193
194 /**
195 * HANDLE FindFirstFile(
196 * LPCTSTR lpFileName,
197 * LPWIN32_FIND_DATA lpFindFileData
198 * )
199 */
200 static FirstFile FindFirstFile(String path) throws WindowsException {
201 try (NativeBuffer buffer = asNativeBuffer(path)) {
202 FirstFile data = new FirstFile();
203 long comp = Blocker.begin();
204 try {
205 FindFirstFile0(buffer.address(), data);
206 } finally {
207 Blocker.end(comp);
208 }
209 return data;
210 }
211 }
212 static class FirstFile {
213 private long handle;
214 private String name;
215 private int attributes;
216
217 private FirstFile() { }
218 public long handle() { return handle; }
219 public String name() { return name; }
220 public int attributes() { return attributes; }
221 }
222 private static native void FindFirstFile0(long lpFileName, FirstFile obj)
223 throws WindowsException;
224
225 /**
226 * HANDLE FindFirstFile(
227 * LPCTSTR lpFileName,
228 * LPWIN32_FIND_DATA lpFindFileData
229 * )
230 */
231 static long FindFirstFile(String path, long address) throws WindowsException {
232 try (NativeBuffer buffer = asNativeBuffer(path)) {
233 long comp = Blocker.begin();
234 try {
235 return FindFirstFile1(buffer.address(), address);
236 } finally {
237 Blocker.end(comp);
238 }
239 }
240 }
241 private static native long FindFirstFile1(long lpFileName, long address)
242 throws WindowsException;
243
244 /**
245 * FindNextFile(
246 * HANDLE hFindFile,
247 * LPWIN32_FIND_DATA lpFindFileData
248 * )
249 *
250 * @return lpFindFileData->cFileName or null
251 */
252 static String FindNextFile(long handle, long address) throws WindowsException {
253 long comp = Blocker.begin();
254 try {
255 return FindNextFile0(handle, address);
256 } finally {
257 Blocker.end(comp);
258 }
259 }
260 private static native String FindNextFile0(long handle, long address)
261 throws WindowsException;
262
263 /**
264 * HANDLE FindFirstStreamW(
265 * LPCWSTR lpFileName,
266 * STREAM_INFO_LEVELS InfoLevel,
267 * LPVOID lpFindStreamData,
268 * DWORD dwFlags
269 * )
270 */
271 static FirstStream FindFirstStream(String path) throws WindowsException {
272 try (NativeBuffer buffer = asNativeBuffer(path)) {
273 FirstStream data = new FirstStream();
274 long comp = Blocker.begin();
275 try {
276 FindFirstStream0(buffer.address(), data);
277 } finally {
278 Blocker.end(comp);
279 }
280 if (data.handle() == WindowsConstants.INVALID_HANDLE_VALUE)
281 return null;
282 return data;
283 }
284 }
285 static class FirstStream {
286 private long handle;
287 private String name;
288
289 private FirstStream() { }
290 public long handle() { return handle; }
291 public String name() { return name; }
292 }
293 private static native void FindFirstStream0(long lpFileName, FirstStream obj)
294 throws WindowsException;
295
296 /*
297 * FindNextStreamW(
298 * HANDLE hFindStream,
299 * LPVOID lpFindStreamData
300 * )
301 */
302 static String FindNextStream(long handle) throws WindowsException {
303 long comp = Blocker.begin();
304 try {
305 return FindNextStream0(handle);
306 } finally {
307 Blocker.end(comp);
308 }
309 }
310 private static native String FindNextStream0(long handle) throws WindowsException;
311
312 /**
313 * FindClose(
314 * HANDLE hFindFile
315 * )
316 */
317 static native void FindClose(long handle) throws WindowsException;
318
319 /**
320 * GetFileInformationByHandle(
321 * HANDLE hFile,
322 * LPBY_HANDLE_FILE_INFORMATION lpFileInformation
323 * )
324 */
325 static void GetFileInformationByHandle(long handle, long address)
326 throws WindowsException
327 {
328 long comp = Blocker.begin();
329 try {
330 GetFileInformationByHandle0(handle, address);
331 } finally {
332 Blocker.end(comp);
333 }
334 }
335 private static native void GetFileInformationByHandle0(long handle, long address)
336 throws WindowsException;
337
338 /**
339 * CopyFileEx(
340 * LPCWSTR lpExistingFileName
341 * LPCWSTR lpNewFileName,
342 * LPPROGRESS_ROUTINE lpProgressRoutine
343 * LPVOID lpData,
344 * LPBOOL pbCancel,
345 * DWORD dwCopyFlags
346 * )
347 */
348 static void CopyFileEx(String source, String target, int flags,
349 long addressToPollForCancel)
350 throws WindowsException
351 {
352 try (NativeBuffer sourceBuffer = asNativeBuffer(source);
353 NativeBuffer targetBuffer = asNativeBuffer(target)) {
354 long comp = Blocker.begin();
355 try {
356 CopyFileEx0(sourceBuffer.address(), targetBuffer.address(), flags,
357 addressToPollForCancel);
358 } finally {
359 Blocker.end(comp);
360 }
361 }
362 }
363 private static native void CopyFileEx0(long existingAddress, long newAddress,
364 int flags, long addressToPollForCancel) throws WindowsException;
365
366 /**
367 * MoveFileEx(
368 * LPCTSTR lpExistingFileName,
369 * LPCTSTR lpNewFileName,
370 * DWORD dwFlags
371 * )
372 */
373 static void MoveFileEx(String source, String target, int flags)
374 throws WindowsException
375 {
376 try (NativeBuffer sourceBuffer = asNativeBuffer(source);
377 NativeBuffer targetBuffer = asNativeBuffer(target)) {
378 long comp = Blocker.begin();
379 try {
380 MoveFileEx0(sourceBuffer.address(), targetBuffer.address(), flags);
381 } finally {
382 Blocker.end(comp);
383 }
384 }
385 }
386 private static native void MoveFileEx0(long existingAddress, long newAddress,
387 int flags) throws WindowsException;
388
389 /**
390 * DWORD GetFileAttributes(
391 * LPCTSTR lpFileName
392 * )
393 */
394 static int GetFileAttributes(String path) throws WindowsException {
395 try (NativeBuffer buffer = asNativeBuffer(path)) {
396 long comp = Blocker.begin();
397 try {
398 return GetFileAttributes0(buffer.address());
399 } finally {
400 Blocker.end(comp);
401 }
402 }
403 }
404 private static native int GetFileAttributes0(long lpFileName)
405 throws WindowsException;
406
407 /**
408 * SetFileAttributes(
409 * LPCTSTR lpFileName,
410 * DWORD dwFileAttributes
411 */
412 static void SetFileAttributes(String path, int dwFileAttributes)
413 throws WindowsException
414 {
415 try (NativeBuffer buffer = asNativeBuffer(path)) {
416 long comp = Blocker.begin();
417 try {
418 SetFileAttributes0(buffer.address(), dwFileAttributes);
419 } finally {
420 Blocker.end(comp);
421 }
422 }
423 }
424 private static native void SetFileAttributes0(long lpFileName,
425 int dwFileAttributes) throws WindowsException;
426
427 /**
428 * GetFileAttributesEx(
429 * LPCTSTR lpFileName,
430 * GET_FILEEX_INFO_LEVELS fInfoLevelId,
431 * LPVOID lpFileInformation
432 * );
433 */
434 static void GetFileAttributesEx(String path, long address) throws WindowsException {
435 try (NativeBuffer buffer = asNativeBuffer(path)) {
436 long comp = Blocker.begin();
437 try {
438 GetFileAttributesEx0(buffer.address(), address);
439 } finally {
440 Blocker.end(comp);
441 }
442 }
443 }
444 private static native void GetFileAttributesEx0(long lpFileName, long address)
445 throws WindowsException;
446
447 /**
448 * SetFileTime(
449 * HANDLE hFile,
450 * CONST FILETIME *lpCreationTime,
451 * CONST FILETIME *lpLastAccessTime,
452 * CONST FILETIME *lpLastWriteTime
453 * )
454 */
455 static void SetFileTime(long handle, long createTime, long lastAccessTime, long lastWriteTime)
456 throws WindowsException
457 {
458 long comp = Blocker.begin();
459 try {
460 SetFileTime0(handle, createTime, lastAccessTime, lastWriteTime);
461 } finally {
462 Blocker.end(comp);
463 }
464 }
465 private static native void SetFileTime0(long handle,
466 long createTime,
467 long lastAccessTime,
468 long lastWriteTime)
469 throws WindowsException;
470
471 /**
472 * SetEndOfFile(
473 * HANDLE hFile
474 * )
475 */
476 static native void SetEndOfFile(long handle) throws WindowsException;
477
478 /**
479 * DWORD GetLogicalDrives(VOID)
480 */
481 static native int GetLogicalDrives() throws WindowsException;
482
483 /**
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 jdk.internal.misc.Unsafe;
29
30 import static sun.nio.fs.WindowsConstants.*;
31
32 /**
33 * Win32 and library calls.
34 */
35
36 class WindowsNativeDispatcher {
37 private WindowsNativeDispatcher() { }
38
39 /**
40 * HANDLE CreateEvent(
41 * LPSECURITY_ATTRIBUTES lpEventAttributes,
42 * BOOL bManualReset,
43 * BOOL bInitialState,
44 * PCTSTR lpName
45 * );
46 */
47 static native long CreateEvent(boolean bManualReset, boolean bInitialState)
50 /**
51 * HANDLE CreateFile(
52 * LPCTSTR lpFileName,
53 * DWORD dwDesiredAccess,
54 * DWORD dwShareMode,
55 * LPSECURITY_ATTRIBUTES lpSecurityAttributes,
56 * DWORD dwCreationDisposition,
57 * DWORD dwFlagsAndAttributes,
58 * HANDLE hTemplateFile
59 * )
60 */
61 static long CreateFile(String path,
62 int dwDesiredAccess,
63 int dwShareMode,
64 long lpSecurityAttributes,
65 int dwCreationDisposition,
66 int dwFlagsAndAttributes)
67 throws WindowsException
68 {
69 try (NativeBuffer buffer = asNativeBuffer(path)) {
70 return CreateFile0(buffer.address(),
71 dwDesiredAccess,
72 dwShareMode,
73 lpSecurityAttributes,
74 dwCreationDisposition,
75 dwFlagsAndAttributes);
76 }
77 }
78 static long CreateFile(String path,
79 int dwDesiredAccess,
80 int dwShareMode,
81 int dwCreationDisposition,
82 int dwFlagsAndAttributes)
83 throws WindowsException
84 {
85 return CreateFile(path, dwDesiredAccess, dwShareMode, 0L,
86 dwCreationDisposition, dwFlagsAndAttributes);
87 }
88 private static native long CreateFile0(long lpFileName,
89 int dwDesiredAccess,
90 int dwShareMode,
91 long lpSecurityAttributes,
92 int dwCreationDisposition,
93 int dwFlagsAndAttributes)
94 throws WindowsException;
95
96 /**
97 * CloseHandle(
98 * HANDLE hObject
99 * )
100 */
101 static native void CloseHandle(long handle);
102
103 /**
104 * DeleteFile(
105 * LPCTSTR lpFileName
106 * )
107 */
108 static void DeleteFile(String path) throws WindowsException {
109 try (NativeBuffer buffer = asNativeBuffer(path)) {
110 DeleteFile0(buffer.address());
111 }
112 }
113 private static native void DeleteFile0(long lpFileName)
114 throws WindowsException;
115
116 /**
117 * CreateDirectory(
118 * LPCTSTR lpPathName,
119 * LPSECURITY_ATTRIBUTES lpSecurityAttributes
120 * )
121 */
122 static void CreateDirectory(String path, long lpSecurityAttributes) throws WindowsException {
123 try (NativeBuffer buffer = asNativeBuffer(path)) {
124 CreateDirectory0(buffer.address(), lpSecurityAttributes);
125 }
126 }
127 private static native void CreateDirectory0(long lpFileName, long lpSecurityAttributes)
128 throws WindowsException;
129
130 /**
131 * RemoveDirectory(
132 * LPCTSTR lpPathName
133 * )
134 */
135 static void RemoveDirectory(String path) throws WindowsException {
136 try (NativeBuffer buffer = asNativeBuffer(path)) {
137 RemoveDirectory0(buffer.address());
138 }
139 }
140 private static native void RemoveDirectory0(long lpFileName)
141 throws WindowsException;
142
143 /**
144 * Marks a file as a sparse file.
145 *
146 * DeviceIoControl(
147 * FSCTL_SET_SPARSE
148 * )
149 */
150 static native void DeviceIoControlSetSparse(long handle)
151 throws WindowsException;
152
153 /**
154 * Retrieves the reparse point data associated with the file or directory.
155 *
156 * DeviceIoControl(
157 * FSCTL_GET_REPARSE_POINT
162
163 /**
164 * Retrieves the size of the specified file.
165 *
166 * BOOL GetFileSizeEx(
167 * HANDLE hFile,
168 * PLARGE_INTEGER lpFileSize
169 * )
170 */
171 static native long GetFileSizeEx(long handle) throws WindowsException;
172
173 /**
174 * HANDLE FindFirstFile(
175 * LPCTSTR lpFileName,
176 * LPWIN32_FIND_DATA lpFindFileData
177 * )
178 */
179 static FirstFile FindFirstFile(String path) throws WindowsException {
180 try (NativeBuffer buffer = asNativeBuffer(path)) {
181 FirstFile data = new FirstFile();
182 FindFirstFile0(buffer.address(), data);
183 return data;
184 }
185 }
186 static class FirstFile {
187 private long handle;
188 private String name;
189 private int attributes;
190
191 private FirstFile() { }
192 public long handle() { return handle; }
193 public String name() { return name; }
194 public int attributes() { return attributes; }
195 }
196 private static native void FindFirstFile0(long lpFileName, FirstFile obj)
197 throws WindowsException;
198
199 /**
200 * HANDLE FindFirstFile(
201 * LPCTSTR lpFileName,
202 * LPWIN32_FIND_DATA lpFindFileData
203 * )
204 */
205 static long FindFirstFile(String path, long address) throws WindowsException {
206 try (NativeBuffer buffer = asNativeBuffer(path)) {
207 return FindFirstFile1(buffer.address(), address);
208 }
209 }
210 private static native long FindFirstFile1(long lpFileName, long address)
211 throws WindowsException;
212
213 /**
214 * FindNextFile(
215 * HANDLE hFindFile,
216 * LPWIN32_FIND_DATA lpFindFileData
217 * )
218 *
219 * @return lpFindFileData->cFileName or null
220 */
221 static String FindNextFile(long handle, long address) throws WindowsException {
222 return FindNextFile0(handle, address);
223 }
224 private static native String FindNextFile0(long handle, long address)
225 throws WindowsException;
226
227 /**
228 * HANDLE FindFirstStreamW(
229 * LPCWSTR lpFileName,
230 * STREAM_INFO_LEVELS InfoLevel,
231 * LPVOID lpFindStreamData,
232 * DWORD dwFlags
233 * )
234 */
235 static FirstStream FindFirstStream(String path) throws WindowsException {
236 try (NativeBuffer buffer = asNativeBuffer(path)) {
237 FirstStream data = new FirstStream();
238 FindFirstStream0(buffer.address(), data);
239 if (data.handle() == WindowsConstants.INVALID_HANDLE_VALUE)
240 return null;
241 return data;
242 }
243 }
244 static class FirstStream {
245 private long handle;
246 private String name;
247
248 private FirstStream() { }
249 public long handle() { return handle; }
250 public String name() { return name; }
251 }
252 private static native void FindFirstStream0(long lpFileName, FirstStream obj)
253 throws WindowsException;
254
255 /*
256 * FindNextStreamW(
257 * HANDLE hFindStream,
258 * LPVOID lpFindStreamData
259 * )
260 */
261 static String FindNextStream(long handle) throws WindowsException {
262 return FindNextStream0(handle);
263 }
264 private static native String FindNextStream0(long handle) throws WindowsException;
265
266 /**
267 * FindClose(
268 * HANDLE hFindFile
269 * )
270 */
271 static native void FindClose(long handle) throws WindowsException;
272
273 /**
274 * GetFileInformationByHandle(
275 * HANDLE hFile,
276 * LPBY_HANDLE_FILE_INFORMATION lpFileInformation
277 * )
278 */
279 static void GetFileInformationByHandle(long handle, long address)
280 throws WindowsException
281 {
282 GetFileInformationByHandle0(handle, address);
283 }
284 private static native void GetFileInformationByHandle0(long handle, long address)
285 throws WindowsException;
286
287 /**
288 * CopyFileEx(
289 * LPCWSTR lpExistingFileName
290 * LPCWSTR lpNewFileName,
291 * LPPROGRESS_ROUTINE lpProgressRoutine
292 * LPVOID lpData,
293 * LPBOOL pbCancel,
294 * DWORD dwCopyFlags
295 * )
296 */
297 static void CopyFileEx(String source, String target, int flags,
298 long addressToPollForCancel)
299 throws WindowsException
300 {
301 try (NativeBuffer sourceBuffer = asNativeBuffer(source);
302 NativeBuffer targetBuffer = asNativeBuffer(target)) {
303 CopyFileEx0(sourceBuffer.address(), targetBuffer.address(), flags, addressToPollForCancel);
304 }
305 }
306 private static native void CopyFileEx0(long existingAddress, long newAddress,
307 int flags, long addressToPollForCancel) throws WindowsException;
308
309 /**
310 * MoveFileEx(
311 * LPCTSTR lpExistingFileName,
312 * LPCTSTR lpNewFileName,
313 * DWORD dwFlags
314 * )
315 */
316 static void MoveFileEx(String source, String target, int flags)
317 throws WindowsException
318 {
319 try (NativeBuffer sourceBuffer = asNativeBuffer(source);
320 NativeBuffer targetBuffer = asNativeBuffer(target)) {
321 MoveFileEx0(sourceBuffer.address(), targetBuffer.address(), flags);
322 }
323 }
324 private static native void MoveFileEx0(long existingAddress, long newAddress,
325 int flags) throws WindowsException;
326
327 /**
328 * DWORD GetFileAttributes(
329 * LPCTSTR lpFileName
330 * )
331 */
332 static int GetFileAttributes(String path) throws WindowsException {
333 try (NativeBuffer buffer = asNativeBuffer(path)) {
334 return GetFileAttributes0(buffer.address());
335 }
336 }
337 private static native int GetFileAttributes0(long lpFileName)
338 throws WindowsException;
339
340 /**
341 * SetFileAttributes(
342 * LPCTSTR lpFileName,
343 * DWORD dwFileAttributes
344 */
345 static void SetFileAttributes(String path, int dwFileAttributes)
346 throws WindowsException
347 {
348 try (NativeBuffer buffer = asNativeBuffer(path)) {
349 SetFileAttributes0(buffer.address(), dwFileAttributes);
350 }
351 }
352 private static native void SetFileAttributes0(long lpFileName,
353 int dwFileAttributes) throws WindowsException;
354
355 /**
356 * GetFileAttributesEx(
357 * LPCTSTR lpFileName,
358 * GET_FILEEX_INFO_LEVELS fInfoLevelId,
359 * LPVOID lpFileInformation
360 * );
361 */
362 static void GetFileAttributesEx(String path, long address) throws WindowsException {
363 try (NativeBuffer buffer = asNativeBuffer(path)) {
364 GetFileAttributesEx0(buffer.address(), address);
365 }
366 }
367 private static native void GetFileAttributesEx0(long lpFileName, long address)
368 throws WindowsException;
369
370 /**
371 * SetFileTime(
372 * HANDLE hFile,
373 * CONST FILETIME *lpCreationTime,
374 * CONST FILETIME *lpLastAccessTime,
375 * CONST FILETIME *lpLastWriteTime
376 * )
377 */
378 static void SetFileTime(long handle, long createTime, long lastAccessTime, long lastWriteTime)
379 throws WindowsException
380 {
381 SetFileTime0(handle, createTime, lastAccessTime, lastWriteTime);
382 }
383 private static native void SetFileTime0(long handle,
384 long createTime,
385 long lastAccessTime,
386 long lastWriteTime)
387 throws WindowsException;
388
389 /**
390 * SetEndOfFile(
391 * HANDLE hFile
392 * )
393 */
394 static native void SetEndOfFile(long handle) throws WindowsException;
395
396 /**
397 * DWORD GetLogicalDrives(VOID)
398 */
399 static native int GetLogicalDrives() throws WindowsException;
400
401 /**
|