/** * Test whether we can attempt SSPI authentication. If false, do not attempt to call any other * SSPIClient methods. * * @return true if it's safe to attempt SSPI authentication */ public boolean isSSPISupported() { try { /* * SSPI is windows-only. Attempt to use JNA to identify the platform. If Waffle is missing we * won't have JNA and this will throw a NoClassDefFoundError. */ if (!Platform.isWindows()) { LOGGER.log(Level.FINE, "SSPI not supported: non-Windows host"); return false; } /* Waffle must be on the CLASSPATH */ Class.forName("waffle.windows.auth.impl.WindowsSecurityContextImpl"); return true; } catch (NoClassDefFoundError ex) { LOGGER.log(Level.WARNING, "SSPI unavailable (no Waffle/JNA libraries?)", ex); return false; } catch (ClassNotFoundException ex) { LOGGER.log(Level.WARNING, "SSPI unavailable (no Waffle/JNA libraries?)", ex); return false; } }
protected static String getSourceBySystem() { if (Platform.isWindows()) { return SRC_WINDOWS_KERNEL_STREAMING; } else if (Platform.isLinux()) { return SRC_VIDEO_FOR_LINUX_2; } else if (Platform.isMac()) { return SRC_QUICKTIME_KIT; } throw new IllegalStateException("Unsupported operating system"); }
/** * Wrapper over platform-dependent system calls to create a symbolic link. * * @return true on success */ // XXX could handle errors better (examine errno, throw exception...) public static boolean makeSymbolicLink(String existingPath, String newPath) { try { if (Platform.isWindows()) { return Kernel32Library.INSTANCE.CreateSymbolicLinkA(newPath, existingPath, null); } else { int status = CLibrary.INSTANCE.symlink(existingPath, newPath); return status == 0; } } catch (UnsatisfiedLinkError e) { // see https://webarchive.jira.com/browse/HER-1979 logger.warning("symbolic links not supported on this platform - " + e); return false; } }
/** * Wrapper over platform-dependent system calls to create a hard link. * * @return true on success */ // XXX could handle errors better (examine errno, throw exception...) public static boolean makeHardLink(String existingPath, String newPath) { try { if (Platform.isWindows()) { return Kernel32Library.INSTANCE.CreateHardLinkA(newPath, existingPath, null); } else { int status = CLibrary.INSTANCE.link(existingPath, newPath); return status == 0; } } catch (UnsatisfiedLinkError e) { // see https://webarchive.jira.com/browse/HER-1979 logger.warning("hard links not supported on this platform - " + e); return false; } }
@Override public List<WebcamDevice> getDevices() { List<WebcamDevice> devices = new ArrayList<WebcamDevice>(); final String factory = GsUtils.getCompatibleSourceFactory(); final Element source = ElementFactory.make(factory, "source"); try { if (Platform.isWindows()) { PropertyProbe probe = PropertyProbe.wrap(source); for (Object name : probe.getValues("device-name")) { devices.add(new Gst1Device(name.toString())); } } else if (Platform.isLinux()) { for (File vfile : NixVideoDevUtils.getVideoFiles()) { devices.add(new Gst1Device(vfile)); } } else { throw new RuntimeException("Platform unsupported by GStreamer capture driver"); } } finally { if (source != null) { source.dispose(); } } return devices; }
if (Platform.isWindows()) {
private static String formatMessage(int code) { return Platform.isWindows() ? "GetLastError() returned " + code : "errno was " + code; }
/** * Gets native library name. * * @return the name of the tesseract library to be loaded using the * <code>Native.register()</code>. */ public static String getTesseractLibName() { return Platform.isWindows() ? LIB_NAME : LIB_NAME_NON_WIN; }
private static NativeCalls getImplInstance() { if (Platform.isLinux()) { return new LinuxNativeCalls(); } if (Platform.isWindows()) { return new WinNativeCalls(); } if (Platform.isSolaris()) { return new SolarisNativeCalls(); } if (Platform.isMac()) { return new MacOSXNativeCalls(); } if (Platform.isFreeBSD()) { return new FreeBSDNativeCalls(); } return new POSIXNativeCalls(); }
public static final boolean isX11() { // TODO: check filesystem for /usr/X11 or some other X11-specific test return !Platform.isWindows() && !Platform.isMac(); } public static final boolean hasRuntimeExec() {
static int getFdFromPcapT(Pointer p) { if (Platform.isWindows()) { return -1; } return p.getInt(0); }
/** Change the alignment of this structure. Re-allocates memory if * necessary. If alignment is {@link #ALIGN_DEFAULT}, the default * alignment for the defining class will be used. * @param alignType desired alignment type */ protected void setAlignType(int alignType) { this.alignType = alignType; if (alignType == ALIGN_DEFAULT) { alignType = Native.getStructureAlignment(getClass()); if (alignType == ALIGN_DEFAULT) { if (Platform.isWindows()) alignType = ALIGN_MSVC; else alignType = ALIGN_GNUC; } } this.actualAlignType = alignType; layoutChanged(); }
else if (Platform.isWindows()) { if (libName.endsWith(".drv") || libName.endsWith(".dll")) { return libName;
private NativeLibrary(String libraryName, String libraryPath, long handle, Map<String, ?> options) { this.libraryName = getLibraryName(libraryName); this.libraryPath = libraryPath; this.handle = handle; Object option = options.get(Library.OPTION_CALLING_CONVENTION); int callingConvention = option instanceof Number ? ((Number)option).intValue() : Function.C_CONVENTION; this.callFlags = callingConvention; this.options = options; this.encoding = (String)options.get(Library.OPTION_STRING_ENCODING); if (this.encoding == null) { this.encoding = Native.getDefaultStringEncoding(); } // Special workaround for w32 kernel32.GetLastError // Short-circuit the function to use built-in GetLastError access if (Platform.isWindows() && "kernel32".equals(this.libraryName.toLowerCase())) { synchronized(functions) { Function f = new Function(this, "GetLastError", Function.ALT_CONVENTION, encoding) { @Override Object invoke(Object[] args, Class<?> returnType, boolean b, int fixedArgs) { return Integer.valueOf(Native.getLastError()); } @Override Object invoke(Method invokingMethod, Class<?>[] paramTypes, Class<?> returnType, Object[] inArgs, Map<String, ?> options) { return Integer.valueOf(Native.getLastError()); } }; functions.put(functionKey("GetLastError", callFlags, encoding), f); } } }
System.out.println("ps_drop: " + ps.getNumPacketsDropped()); System.out.println("ps_ifdrop: " + ps.getNumPacketsDroppedByIf()); if (Platform.isWindows()) { System.out.println("bs_capt: " + ps.getNumPacketsCaptured());
System.out.println("ps_drop: " + ps.getNumPacketsDropped()); System.out.println("ps_ifdrop: " + ps.getNumPacketsDroppedByIf()); if (Platform.isWindows()) { System.out.println("bs_capt: " + ps.getNumPacketsCaptured());
System.out.println("ps_drop: " + ps.getNumPacketsDropped()); System.out.println("ps_ifdrop: " + ps.getNumPacketsDroppedByIf()); if (Platform.isWindows()) { System.out.println("bs_capt: " + ps.getNumPacketsCaptured());
System.out.println("ps_drop: " + ps.getNumPacketsDropped()); System.out.println("ps_ifdrop: " + ps.getNumPacketsDroppedByIf()); if (Platform.isWindows()) { System.out.println("bs_capt: " + ps.getNumPacketsCaptured());
if (Platform.isWindows()) { IntByReference pcapStatSize = new IntByReference(); Pointer psp = PcapLibrary.INSTANCE.win_pcap_stats_ex(handle, pcapStatSize);