use of com.sun.jna.platform.win32.WinBase.FILE_DISPOSITION_INFO in project jna by java-native-access.
the class Kernel32Test method testSetFileInformationByHandleFileDispositionInfo.
public void testSetFileInformationByHandleFileDispositionInfo() throws IOException, InterruptedException {
File tmp = File.createTempFile("testSetFileInformationByHandleFileDispositionInfo", "jna");
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_WRITE | WinNT.DELETE, WinNT.FILE_SHARE_WRITE, new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
assertFalse(WinBase.INVALID_HANDLE_VALUE.equals(hFile));
try {
FILE_DISPOSITION_INFO fdi = new FILE_DISPOSITION_INFO(true);
if (false == Kernel32.INSTANCE.SetFileInformationByHandle(hFile, WinBase.FileDispositionInfo, fdi.getPointer(), new DWORD(FILE_DISPOSITION_INFO.sizeOf())))
fail("SetFileInformationByHandle failed with " + Kernel32.INSTANCE.GetLastError());
} finally {
Kernel32.INSTANCE.CloseHandle(hFile);
}
assertFalse(Files.exists(Paths.get(tmp.getAbsolutePath())));
}
Aggregations