/** * @return Obtains the human-readable error message text from the last error * that occurred by invocating {@code Kernel32.GetLastError()}. */ public static String getLastErrorMessage() { return Kernel32Util.formatMessageFromLastErrorCode(Kernel32.INSTANCE .GetLastError()); }
WinProcess( int pid ) throws IOException { handle = Kernel32.INSTANCE .OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_SUSPEND_RESUME | PROCESS_TERMINATE | PROCESS_SYNCHRONIZE, false, pid ); if ( handle == null ) { throw new IOException( "OpenProcess failed: " + Kernel32Util.formatMessageFromLastErrorCode( Kernel32.INSTANCE.GetLastError() ) ); } this.pid = pid; }
public void moveToTrash(File[] files) throws IOException { Shell32 shell = Shell32.INSTANCE; ShellAPI.SHFILEOPSTRUCT fileop = new ShellAPI.SHFILEOPSTRUCT(); fileop.wFunc = ShellAPI.FO_DELETE; String[] paths = new String[files.length]; for (int i=0;i < paths.length;i++) { paths[i] = files[i].getAbsolutePath(); } fileop.pFrom = fileop.encodePaths(paths); fileop.fFlags = ShellAPI.FOF_ALLOWUNDO|ShellAPI.FOF_NO_UI; int ret = shell.SHFileOperation(fileop); if (ret != 0) { throw new IOException("Move to trash failed: " + fileop.pFrom + ": " + Kernel32Util.formatMessageFromLastErrorCode(ret)); } if (fileop.fAnyOperationsAborted) { throw new IOException("Move to trash aborted"); } } }
public static void msync(RandomAccessFile raf, long addr, long length) throws IOException { int retry = 0; boolean success; int lastError = 0; // FlushViewOfFile can fail with ERROR_LOCK_VIOLATION if the memory system is writing dirty // pages to disk. As there is no way to synchronize the flushing then we retry a limited // number of times. do { success = KERNEL_32.FlushViewOfFile(new Pointer(addr), new SIZE_T(length)); if (success || (lastError = KERNEL_32.GetLastError()) != ERROR_LOCK_VIOLATION) break; retry++; } while (retry < 3); if (success) { // Finally calls FlushFileBuffers raf.getChannel().force(false); } else { throw new IOException(Kernel32Util.formatMessageFromLastErrorCode(lastError)); } }
public void moveToTrash(File[] files) throws IOException { Shell32 shell = Shell32.INSTANCE; ShellAPI.SHFILEOPSTRUCT fileop = new ShellAPI.SHFILEOPSTRUCT(); fileop.wFunc = ShellAPI.FO_DELETE; String[] paths = new String[files.length]; for (int i=0;i < paths.length;i++) { paths[i] = files[i].getAbsolutePath(); } fileop.pFrom = new WString(fileop.encodePaths(paths)); fileop.fFlags = ShellAPI.FOF_ALLOWUNDO|ShellAPI.FOF_NO_UI; int ret = shell.SHFileOperation(fileop); if (ret != 0) { throw new IOException("Move to trash failed: " + fileop.pFrom + ": " + Kernel32Util.formatMessageFromLastErrorCode(ret)); } if (fileop.fAnyOperationsAborted) { throw new IOException("Move to trash aborted"); } } }
throw new IOException("ReadDirectoryChangesW failed on " + finfo.file + ", handle " + handle + ": '" + Kernel32Util.formatMessageFromLastErrorCode(err) + "' (" + err + ")");
throw new IOException("ReadDirectoryChangesW failed on " + finfo.file + ", handle " + handle + ": '" + Kernel32Util.formatMessageFromLastErrorCode(err) + "' (" + err + ")");
throw new IOException("ReadDirectoryChangesW failed on " + finfo.file + ": '" + Kernel32Util.formatMessageFromLastErrorCode(err) + "' (" + err + ")");
throw new IOException("ReadDirectoryChangesW failed on " + finfo.file + ": '" + Kernel32Util.formatMessageFromLastErrorCode(err) + "' (" + err + ")");