Java Code Examples for com.intellij.openapi.util.SystemInfo#is64Bit()

The following examples show how to use com.intellij.openapi.util.SystemInfo#is64Bit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RunnerMediator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static String getRunnerPath() {
  if (!SystemInfo.isWindows) {
    throw new IllegalStateException("There is no need of runner under unix based OS");
  }
  final String path = System.getenv(IDEA_RUNNERW);
  if (path != null) {
    if (new File(path).exists()) {
      return path;
    }
    LOG.warn("Cannot locate " + RUNNERW + " by " + IDEA_RUNNERW + " environment variable (" + path + ")");
  }
  File runnerw = new File(ContainerPathManager.get().getBinPath(), SystemInfo.is64Bit ? RUNNERW64 : RUNNERW);
  if (runnerw.exists()) {
    return runnerw.getPath();
  }
  LOG.warn("Cannot locate " + RUNNERW + " by default path (" + runnerw.getAbsolutePath() + ")");
  return null;
}
 
Example 2
Source File: VMOptions.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static File getWriteFile() {
  String vmOptionsFile = System.getProperty("jb.vmOptionsFile");
  if (vmOptionsFile == null) {
    // launchers should specify a path to an options file used to configure a JVM
    return null;
  }

  vmOptionsFile = new File(vmOptionsFile).getAbsolutePath();
  if (!FileUtil.isAncestor(ContainerPathManager.get().getHomePath(), vmOptionsFile, true)) {
    // a file is located outside the IDE installation - meaning it is safe to overwrite
    return new File(vmOptionsFile);
  }

  File appHomeDirectory = ContainerPathManager.get().getAppHomeDirectory();

  String fileName = ApplicationNamesInfo.getInstance().getProductName().toLowerCase(Locale.US);
  if (SystemInfo.is64Bit && !SystemInfo.isMac) fileName += "64";
  if (SystemInfo.isWindows) fileName += ".exe";
  fileName += ".vmoptions";
  return new File(appHomeDirectory, fileName);
}
 
Example 3
Source File: PlatformOrPluginUpdateChecker.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static PluginId getPlatformPluginId() {
  boolean isJreBuild = isJreBuild();
  boolean is64Bit = SystemInfo.is64Bit;
  if (SystemInfo.isWindows) {
    return isJreBuild ? (is64Bit ? ourWin64 : ourWin) : ourWinNoJre;
  }
  else if (SystemInfo.isMac) {
    return isJreBuild ? ourMac64 : ourMacNoJre;
  }
  else {
    return isJreBuild ? (is64Bit ? ourLinux64 : ourLinux) : ourLinuxNoJre;
  }
}
 
Example 4
Source File: NativeLibraryLoader.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static String mapLibraryName(@Nonnull String libName) {
  String baseName = libName;
  if (SystemInfo.is64Bit) {
    baseName = baseName.replace("32", "") + "64";
  }
  String fileName = System.mapLibraryName(baseName);
  if (SystemInfo.isMac) {
    fileName = fileName.replace(".jnilib", ".dylib");
  }
  return fileName;
}
 
Example 5
Source File: WindowsDefenderChecker.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @return full path to consulo.exe or consulo64.exe
 */
@Nonnull
private static String getExecutableOnWindows() {
  if (SystemInfo.is64Bit) {
    return "consulo64.exe";
  }
  else {
    return "consulo.exe";
  }
}
 
Example 6
Source File: X11UiUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
private <T> T getWindowProperty(long window, long name, long type, long expectedFormat) throws Exception {
  T property = null;

  long data = unsafe.allocateMemory(64);
  awtLock.invoke(null);
  try {
    unsafe.setMemory(data, 64, (byte)0);

    int result = (Integer)XGetWindowProperty.invoke(
      null, display, window, name, 0l, 65535l, (long)False, type, data, data + 8, data + 16, data + 24, data + 32);
    if (result == 0) {
      int format = unsafe.getInt(data + 8);
      long pointer = SystemInfo.is64Bit ? unsafe.getLong(data + 32) : unsafe.getInt(data + 32);

      if (pointer != None && format == expectedFormat) {
        int length = SystemInfo.is64Bit ? (int)unsafe.getLong(data + 16) : unsafe.getInt(data + 16);
        if (format == FORMAT_BYTE) {
          byte[] bytes = new byte[length];
          for (int i = 0; i < length; i++) bytes[i] = unsafe.getByte(pointer + i);
          property = (T)bytes;
        }
        else if (format == FORMAT_LONG) {
          long[] values = newLongArray(length);
          for (int i = 0; i < length; i++) {
            values[i] = SystemInfo.is64Bit ? unsafe.getLong(pointer + 8 * i) : unsafe.getInt(pointer + 4 * i);
          }
          property = (T)values;
        }
        else if (format != None) {
          LOG.info("unexpected format: " + format);
        }
      }

      if (pointer != None) XFree.invoke(null, pointer);

    }
  }
  finally {
    awtUnlock.invoke(null);
    unsafe.freeMemory(data);
  }

  return property;
}