static void addConsoleCtrlHandler(ConsoleCtrlHandler handler) { // The console Ctrl handler is necessary on Windows platforms only. if (Constants.WINDOWS) { try { boolean result = JNAKernel32Library.getInstance().addConsoleCtrlHandler(handler); if (result) { logger.debug("console ctrl handler correctly set"); } else { logger.warn("unknown error {} when adding console ctrl handler", Native.getLastError()); } } catch (UnsatisfiedLinkError e) { // this will have already been logged by Kernel32Library, no need to repeat it } } }
/** * Retrieves the short path form of the specified path. * * @param path the path * @return the short path name (or the original path if getting the short path name fails for any reason) */ static String getShortPathName(String path) { assert Constants.WINDOWS; try { final WString longPath = new WString("\\\\?\\" + path); // first we get the length of the buffer needed final int length = JNAKernel32Library.getInstance().GetShortPathNameW(longPath, null, 0); if (length == 0) { logger.warn("failed to get short path name: {}", Native.getLastError()); return path; } final char[] shortPath = new char[length]; // knowing the length of the buffer, now we get the short name if (JNAKernel32Library.getInstance().GetShortPathNameW(longPath, shortPath, length) > 0) { return Native.toString(shortPath); } else { logger.warn("failed to get short path name: {}", Native.getLastError()); return path; } } catch (final UnsatisfiedLinkError e) { return path; } }
JNAKernel32Library lib = JNAKernel32Library.getInstance();
JNAKernel32Library.getInstance(); } catch (Exception ignored) {
static void tryVirtualLock() { JNAKernel32Library kernel = JNAKernel32Library.getInstance(); Pointer process = null; try {
static void addConsoleCtrlHandler(ConsoleCtrlHandler handler) { // The console Ctrl handler is necessary on Windows platforms only. if (Constants.WINDOWS) { try { boolean result = JNAKernel32Library.getInstance().addConsoleCtrlHandler(handler); if (result) { logger.debug("console ctrl handler correctly set"); } else { logger.warn("unknown error {} when adding console ctrl handler", Native.getLastError()); } } catch (UnsatisfiedLinkError e) { // this will have already been logged by Kernel32Library, no need to repeat it } } }
static void addConsoleCtrlHandler(ConsoleCtrlHandler handler) { // The console Ctrl handler is necessary on Windows platforms only. if (Constants.WINDOWS) { try { boolean result = JNAKernel32Library.getInstance().addConsoleCtrlHandler(handler); if (result) { logger.debug("console ctrl handler correctly set"); } else { logger.warn("unknown error {} when adding console ctrl handler", Native.getLastError()); } } catch (UnsatisfiedLinkError e) { // this will have already been logged by Kernel32Library, no need to repeat it } } }
static void addConsoleCtrlHandler(ConsoleCtrlHandler handler) { // The console Ctrl handler is necessary on Windows platforms only. if (Constants.WINDOWS) { try { boolean result = JNAKernel32Library.getInstance().addConsoleCtrlHandler(handler); if (result) { logger.debug("console ctrl handler correctly set"); } else { logger.warn("unknown error {} when adding console ctrl handler", Native.getLastError()); } } catch (UnsatisfiedLinkError e) { // this will have already been logged by Kernel32Library, no need to repeat it } } }
/** * Retrieves the short path form of the specified path. * * @param path the path * @return the short path name (or the original path if getting the short path name fails for any reason) */ static String getShortPathName(String path) { assert Constants.WINDOWS; try { final WString longPath = new WString("\\\\?\\" + path); // first we get the length of the buffer needed final int length = JNAKernel32Library.getInstance().GetShortPathNameW(longPath, null, 0); if (length == 0) { logger.warn("failed to get short path name: {}", Native.getLastError()); return path; } final char[] shortPath = new char[length]; // knowing the length of the buffer, now we get the short name if (JNAKernel32Library.getInstance().GetShortPathNameW(longPath, shortPath, length) > 0) { return Native.toString(shortPath); } else { logger.warn("failed to get short path name: {}", Native.getLastError()); return path; } } catch (final UnsatisfiedLinkError e) { return path; } }
/** * Retrieves the short path form of the specified path. * * @param path the path * @return the short path name (or the original path if getting the short path name fails for any reason) */ static String getShortPathName(String path) { assert Constants.WINDOWS; try { final WString longPath = new WString("\\\\?\\" + path); // first we get the length of the buffer needed final int length = JNAKernel32Library.getInstance().GetShortPathNameW(longPath, null, 0); if (length == 0) { logger.warn("failed to get short path name: {}", Native.getLastError()); return path; } final char[] shortPath = new char[length]; // knowing the length of the buffer, now we get the short name if (JNAKernel32Library.getInstance().GetShortPathNameW(longPath, shortPath, length) > 0) { return Native.toString(shortPath); } else { logger.warn("failed to get short path name: {}", Native.getLastError()); return path; } } catch (final UnsatisfiedLinkError e) { return path; } }
static void addConsoleCtrlHandler(ConsoleCtrlHandler handler) { // The console Ctrl handler is necessary on Windows platforms only. if (Constants.WINDOWS) { try { boolean result = JNAKernel32Library.getInstance().addConsoleCtrlHandler(handler); if (result) { logger.debug("console ctrl handler correctly set"); } else { logger.warn("unknown error " + Native.getLastError() + " when adding console ctrl handler:"); } } catch (UnsatisfiedLinkError e) { // this will have already been logged by Kernel32Library, no need to repeat it } } }
JNAKernel32Library lib = JNAKernel32Library.getInstance();
JNAKernel32Library lib = JNAKernel32Library.getInstance();
JNAKernel32Library lib = JNAKernel32Library.getInstance();
JNAKernel32Library lib = JNAKernel32Library.getInstance();
JNAKernel32Library.getInstance(); } catch (Exception ignored) {
static void tryVirtualLock() { JNAKernel32Library kernel = JNAKernel32Library.getInstance(); Pointer process = null; try {
static void tryVirtualLock() { JNAKernel32Library kernel = JNAKernel32Library.getInstance(); Pointer process = null; try {
static void tryVirtualLock() { JNAKernel32Library kernel = JNAKernel32Library.getInstance(); Pointer process = null; try {
static void tryVirtualLock() { JNAKernel32Library kernel = JNAKernel32Library.getInstance(); Pointer process = null; try {