当前位置: 首页>>代码示例>>Java>>正文


Java Platform.isMac方法代码示例

本文整理汇总了Java中com.sun.jna.Platform.isMac方法的典型用法代码示例。如果您正苦于以下问题:Java Platform.isMac方法的具体用法?Java Platform.isMac怎么用?Java Platform.isMac使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jna.Platform的用法示例。


在下文中一共展示了Platform.isMac方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstance

import com.sun.jna.Platform; //导入方法依赖的package包/类
/**
 * @return an instance of this class.
 */
public static NativeLibExporter getInstance() {
    if (instance == null) {
        instance = new NativeLibExporter();

        try {
            if (Platform.isMac())
                instance.exportLibrary("lib/darwin/libmediainfo.dylib");
            else if (Platform.isWindows() && Platform.is64Bit())
                instance.exportLibrary("lib/win64/MediaInfo64.dll");
            else if (Platform.isWindows())
                instance.exportLibrary("lib/win32/MediaInfo.dll");
        } catch (Throwable e) {
            System.err.println(e.getMessage());
        }
    }

    return instance;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:22,代码来源:NativeLibExporter.java

示例2: getImplInstance

import com.sun.jna.Platform; //导入方法依赖的package包/类
private static final 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();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:NativeCallsJNAImpl.java

示例3: getPlatformFolder

import com.sun.jna.Platform; //导入方法依赖的package包/类
private static String getPlatformFolder() {
    String result;

    if (Platform.isMac()) {
        result = "macosx";
    } else if (Platform.isWindows()) {
        result = "win";
    } else if (Platform.isLinux()) {
        result = "linux";
    } else if (Platform.isFreeBSD()) {
        result = "freebsd";
    } else if (Platform.isOpenBSD()) {
        result = "openbsd";
    } else {
        throw new IllegalStateException("Platform " + Platform.getOSType() + " is not supported");
    }

    return result;
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:20,代码来源:PtyUtil.java

示例4: open

import com.sun.jna.Platform; //导入方法依赖的package包/类
public synchronized MediaInfo open(File file) throws IOException, IllegalArgumentException {
	if (!file.isFile() || file.length() < 64 * 1024) {
		throw new IllegalArgumentException("Invalid media file: " + file);
	}

	String path = file.getCanonicalPath();

	// on Mac files that contain accents cannot be opened via JNA WString file paths due to encoding differences so we use the buffer interface instead for these files
	if (Platform.isMac() && !StandardCharsets.US_ASCII.newEncoder().canEncode(path)) {
		try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
			if (openViaBuffer(raf)) {
				throw new IOException("Failed to initialize media info buffer: " + path);
			}
		}
	}

	if (0 == MediaInfoLibrary.INSTANCE.Open(handle, new WString(path))) {
		// failed to open file
		throw new IOException("Failed to open media file: " + path);
	}

	return this;
}
 
开发者ID:oriley-me,项目名称:crate,代码行数:24,代码来源:MediaInfo.java

示例5: getUnixUID

import com.sun.jna.Platform; //导入方法依赖的package包/类
/**
 * Gets the user ID on Unix based systems. This should not change during a
 * session and the lookup is expensive, so we cache the result.
 *
 * @return The Unix user ID
 * @throws IOException
 */
public static int getUnixUID() throws IOException {
	if (
		Platform.isAIX() || Platform.isFreeBSD() || Platform.isGNU() || Platform.iskFreeBSD() ||
		Platform.isLinux() || Platform.isMac() || Platform.isNetBSD() || Platform.isOpenBSD() ||
		Platform.isSolaris()
	) {
		synchronized (unixUIDLock) {
			if (unixUID < 0) {
				String response;
			    Process id;
				id = Runtime.getRuntime().exec("id -u");
			    try (BufferedReader reader = new BufferedReader(new InputStreamReader(id.getInputStream(), Charset.defaultCharset()))) {
			    	response = reader.readLine();
			    }
			    try {
			    	unixUID = Integer.parseInt(response);
			    } catch (NumberFormatException e) {
			    	throw new UnsupportedOperationException("Unexpected response from OS: " + response, e);
			    }
			}
			return unixUID;
		}
	}
	throw new UnsupportedOperationException("getUnixUID can only be called on Unix based OS'es");
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:33,代码来源:FileUtil.java

示例6: getPipeProcess

import com.sun.jna.Platform; //导入方法依赖的package包/类
public ProcessWrapper getPipeProcess() {
	if (!Platform.isWindows()) {
		OutputParams mkfifo_vid_params = new OutputParams(configuration);
		mkfifo_vid_params.maxBufferSize = 0.1;
		mkfifo_vid_params.log = true;
		String cmdArray[];

		if (Platform.isMac() || Platform.isFreeBSD() || Platform.isSolaris()) {
			cmdArray = new String[] {"mkfifo", "-m", "777", linuxPipeName};
		} else {
			cmdArray = new String[] {"mkfifo", "--mode=777", linuxPipeName};
		}

		ProcessWrapperImpl mkfifo_vid_process = new ProcessWrapperImpl(cmdArray, mkfifo_vid_params);
		return mkfifo_vid_process;
	}

	return mk;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:20,代码来源:PipeProcess.java

示例7: byName

import com.sun.jna.Platform; //导入方法依赖的package包/类
public static Process byName(String name) {
	if (Platform.isWindows()) {
		Tlhelp32.PROCESSENTRY32.ByReference entry = new Tlhelp32.PROCESSENTRY32.ByReference();
		Pointer snapshot = Kernel32.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPALL.intValue(), 0);
		try {
			while (Kernel32.Process32Next(snapshot, entry)) {
				String processName = Native.toString(entry.szExeFile);
				if (name.equals(processName)) {
					return byId(entry.th32ProcessID.intValue());
				}
			}
		} finally {
			Kernel32.CloseHandle(snapshot);
		}
	} else if (Platform.isMac() || Platform.isLinux()) {
		return byId(Utils.exec("bash", "-c", "ps -A | grep -m1 \"" + name + "\" | awk '{print $1}'"));
	} else {
		throw new UnsupportedOperationException("Unknown operating system! (" + System.getProperty("os.name") + ")");
	}
	throw new IllegalStateException("Process '" + name + "' was not found. Are you sure its running?");
}
 
开发者ID:Jonatino,项目名称:Java-Memory-Manipulation,代码行数:22,代码来源:Processes.java

示例8: byId

import com.sun.jna.Platform; //导入方法依赖的package包/类
public static Process byId(int id) {
	if ((Platform.isMac() || Platform.isLinux()) && !isSudo()) {
		throw new RuntimeException("You need to run as root/sudo for unix/osx based environments.");
	}
	
	if (Platform.isWindows()) {
		return new Win32Process(id, Kernel32.OpenProcess(0x438, true, id));
	} else if (Platform.isLinux()) {
		return new UnixProcess(id);
	} else if (Platform.isMac()) {
		IntByReference out = new IntByReference();
		if (mac.task_for_pid(mac.mach_task_self(), id, out) != 0) {
			throw new IllegalStateException("Failed to find mach task port for process, ensure you are running as sudo.");
		}
		return new MacProcess(id, out.getValue());
	}
	throw new IllegalStateException("Process " + id + " was not found. Are you sure its running?");
}
 
开发者ID:Jonatino,项目名称:Java-Memory-Manipulation,代码行数:19,代码来源:Processes.java

示例9: findMobileLibrary

import com.sun.jna.Platform; //导入方法依赖的package包/类
private static String findMobileLibrary() {
	if (Platform.isWindows()) {
		String path;
	    try {
	    	path = getMDPath(true);
	    	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "iTunesMobileDeviceDLL");
	    } catch (Exception ignored) {
	    	try {
		    	path = getMDPath(false);
		    	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "iTunesMobileDeviceDLL");
	    	} catch (Exception ignored1) {
	    		log.info(ignored.getMessage());
	    		return "";
	    	}
		}
    	File f = new File(path);
    	if (f.exists())
    		return path;
	} else {
		if (Platform.isMac()) {
			return "/System/Library/PrivateFrameworks/MobileDevice.framework/MobileDevice";
		}
	}
	return "";
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:26,代码来源:LibraryFinder.java

示例10: findCoreLibrary

import com.sun.jna.Platform; //导入方法依赖的package包/类
private static String findCoreLibrary() {
    String path="";
    if (Platform.isWindows()) {
    	try {
	    	path = getCPath(true);
	       	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "InstallDir");
    	} catch (Exception ignored) {
    		try {
		    	path = getCPath(false);
		       	path = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, path, "InstallDir");
    		} catch (Exception ignored1) {
    			return "";
    		}
    	}
       	path = path + "CoreFoundation.dll";
       	File f = new File(path);
       	if (f.exists())
       		return path;
    } else if (Platform.isMac()) {
         return "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";
    }
    return "";
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:24,代码来源:LibraryFinder.java

示例11: getPlatformFolder

import com.sun.jna.Platform; //导入方法依赖的package包/类
private static String getPlatformFolder() {
  String result;

  if (Platform.isMac()) {
    result = "macosx";
  } else if (Platform.isWindows()) {
    result = "win";
  } else if (Platform.isLinux()) {
    result = "linux";
  } else if (Platform.isFreeBSD()) {
    result = "freebsd";
  } else if (Platform.isOpenBSD()) {
    result = "openbsd";
  } else {
    throw new IllegalStateException("Platform " + Platform.getOSType() + " is not supported");
  }

  return result;
}
 
开发者ID:traff,项目名称:pty4j,代码行数:20,代码来源:PtyUtil.java

示例12: openLib

import com.sun.jna.Platform; //导入方法依赖的package包/类
public static WinscardLibInfo openLib() {
	String libraryName = Platform.isWindows() ? WINDOWS_PATH : Platform.isMac() ? MAC_PATH : PCSC_PATH;
	HashMap<String, Object> options = new HashMap<String, Object>();
	if (Platform.isWindows()) {
		options.put(Library.OPTION_FUNCTION_MAPPER, new WindowsFunctionMapper());
	} else if (Platform.isMac()) {
		options.put(Library.OPTION_FUNCTION_MAPPER, new MacFunctionMapper());
	}
	WinscardLibrary lib = (WinscardLibrary) Native.loadLibrary(libraryName, WinscardLibrary.class, options);
	NativeLibrary nativeLibrary = NativeLibrary.getInstance(libraryName);
	// SCARD_PCI_* is #defined to the following symbols (both pcsclite and winscard)
	ScardIoRequest SCARD_PCI_T0 = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardT0Pci"));
	ScardIoRequest SCARD_PCI_T1 = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardT1Pci"));
	ScardIoRequest SCARD_PCI_RAW = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardRawPci"));
	SCARD_PCI_T0.read();
	SCARD_PCI_T1.read();
	SCARD_PCI_RAW.read();
	SCARD_PCI_T0.setAutoSynch(false);
	SCARD_PCI_T1.setAutoSynch(false);
	SCARD_PCI_RAW.setAutoSynch(false);
	return new WinscardLibInfo(lib, SCARD_PCI_T0, SCARD_PCI_T1, SCARD_PCI_RAW);
}
 
开发者ID:jnasmartcardio,项目名称:jnasmartcardio,代码行数:23,代码来源:Winscard.java

示例13: getOpener

import com.sun.jna.Platform; //导入方法依赖的package包/类
private Opener getOpener()
{
	if( Platform.isWindows() )
	{
		final Permissions permissions = new Permissions();
		permissions.add(new AllPermission());
		final AccessControlContext context = new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain(
			null, permissions)});
		return AccessController.doPrivileged(new PrivilegedAction<Opener>()
		{
			@Override
			public Opener run()
			{
				return new WindowsOpener();
			}
		}, context);
	}

	if( Platform.isLinux() )
	{
		return new LinuxOpener();
	}

	if( Platform.isMac() )
	{
		return new MacOpener();
	}

	throw new UnsupportedOperationException("This platform is not supported");
}
 
开发者ID:equella,项目名称:Equella,代码行数:31,代码来源:InPlaceEditAppletLauncher.java

示例14: initSodium

import com.sun.jna.Platform; //导入方法依赖的package包/类
@Before
public void initSodium()
{
	String platform = System.getProperty("os.name");
	logger.info("Platform: " + platform);
	if (Platform.isMac())
	{
		libraryPath = "/usr/local/lib/libsodium.dylib";
		logger.info("Library path in Mac: " + libraryPath);
	}
	else if (Platform.isWindows())
	{
		//libraryPath = "C:/libsodium/libsodium.dll";
		libraryPath = "d:/muquit/libsodium-1.0.15/x64/Release/v141/dynamic/libsodium.dll";
		logger.info("Library path in Windows: " + libraryPath);
	}
	else
	{
		libraryPath = "/usr/local/lib/libsodium.so";
		logger.info("Library path in "  + "platform: " + platform + " " + libraryPath);
		
	}
	logger.info("Initialize libsodium...");
	SodiumLibrary.setLibraryPath(libraryPath);
	logger.info("sodium object: " + Integer.toHexString(System.identityHashCode(sodium())));
	logger.info("Library path: " + libraryPath);
	String v = sodium().sodium_version_string();
	logger.info("libsodium version: " + v);
}
 
开发者ID:muquit,项目名称:libsodium-jna,代码行数:30,代码来源:TestSodiumLibrary.java

示例15: mapSharedLibraryName

import com.sun.jna.Platform; //导入方法依赖的package包/类
static String mapSharedLibraryName(String libName) {
    if (Platform.isMac()) {
        if (libName.startsWith("lib")
            && (libName.endsWith(".dylib")
                || libName.endsWith(".jnilib"))) {
            return libName;
        }
        String name = System.mapLibraryName(libName);
        // On MacOSX, System.mapLibraryName() returns the .jnilib extension
        // (the suffix for JNI libraries); ordinarily shared libraries have
        // a .dylib suffix
        if (name.endsWith(".jnilib")) {
            return name.substring(0, name.lastIndexOf(".jnilib")) + ".dylib";
        }
        return name;
    }
    else if (Platform.isLinux() || Platform.isFreeBSD()) {
        if (isVersionedName(libName) || libName.endsWith(".so")) {
            // A specific version was requested - use as is for search
            return libName;
        }
    }
    else if (Platform.isAIX()) {	// can be libx.a, libx.a(shr.o), libx.so
        if (libName.startsWith("lib")) {
            return libName;
        }
    }
    else if (Platform.isWindows()) {
        if (libName.endsWith(".drv") || libName.endsWith(".dll")) {
            return libName;
        }
    }

    return System.mapLibraryName(libName);
}
 
开发者ID:xtuhcy,项目名称:webkit4j,代码行数:36,代码来源:InstallLibs.java


注:本文中的com.sun.jna.Platform.isMac方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。