Java 类ch.qos.logback.core.util.EnvUtil 实例源码

项目:bartleby    文件:ConsoleAppender.java   
@Override
public void start() {
  OutputStream targetStream = target.getStream();
  // enable jansi only on Windows and only if withJansi set to true
  if (EnvUtil.isWindows() && withJansi) {
    targetStream = getTargetStreamForWindows(targetStream);
  }
  setOutputStream(targetStream);
  super.start();
}
项目:bartleby    文件:RenameUtil.java   
/**
 * Attempts tp determine whether both files are on different volumes. Returns true if we could determine that
 * the files are on different volumes. Returns false otherwise or if an error occurred while doing the check.
 *
 * @param srcFile
 * @param targetFile
 * @return true if on different volumes, false otherwise or if an error occurred
 */
 boolean areOnDifferentVolumes(File srcFile, File targetFile) throws RolloverFailure {
  if (!EnvUtil.isJDK7OrHigher())
    return false;

  File parentOfTarget = targetFile.getParentFile();

  try {
    boolean onSameFileStore = FileStoreUtil.areOnSameFileStore(srcFile, parentOfTarget);
    return !onSameFileStore;
  } catch (RolloverFailure rf) {
    addWarn("Error while checking file store equality", rf);
    return false;
  }
}
项目:bartleby    文件:IfAction.java   
@Override
public void begin(InterpretationContext ic, String name, Attributes attributes)
    throws ActionException {

  IfState state = new IfState();
  boolean emptyStack = stack.isEmpty();
  stack.push(state);

  if(!emptyStack) {
    return;
  }

  ic.pushObject(this);
  if(!EnvUtil.isJaninoAvailable()) {
     addError(MISSING_JANINO_MSG);
     addError(MISSING_JANINO_SEE);
     return;
   }

  state.active = true;
  Condition condition = null;
  String conditionAttribute = attributes.getValue(CONDITION_ATTR);


  if (!OptionHelper.isEmpty(conditionAttribute)) {
    conditionAttribute = OptionHelper.substVars(conditionAttribute, ic, context);
    PropertyEvalScriptBuilder pesb = new PropertyEvalScriptBuilder(ic);
    pesb.setContext(context);
    try {
      condition = pesb.build(conditionAttribute);
    } catch (Exception e) {
      addError("Failed to parse condition ["+conditionAttribute+"]", e);
    }

    if(condition!=null) {
      state.boolResult = condition.evaluate();
    }

  }
}
项目:bartleby    文件:FileStoreUtilTest.java   
@Test
public void filesOnSameFolderShouldBeOnTheSameFileStore() throws RolloverFailure, IOException {
  if(!EnvUtil.isJDK7OrHigher())
    return;

  File parent = new File(pathPrefix);
  File file = new File(pathPrefix+"filesOnSameFolderShouldBeOnTheSameFileStore");
  FileUtil.createMissingParentDirectories(file);
  file.createNewFile();
  assertTrue(FileStoreUtil.areOnSameFileStore(parent, file));
}
项目:bartleby    文件:FileStoreUtilTest.java   
@Ignore
@Test
public void manual_filesOnDifferentVolumesShouldBeDetectedAsSuch() throws RolloverFailure {
  if(!EnvUtil.isJDK7OrHigher())
    return;

  // author's computer has two volumes
  File c = new File("c:/tmp/");
  File d = new File("d:/");
  assertFalse(FileStoreUtil.areOnSameFileStore(c, d));
}
项目:bartleby    文件:DBAppenderIntegrationTest.java   
static boolean isConformingHostAndJDK16OrHigher(String[] conformingHostList) {
  if (!EnvUtil.isJDK6OrHigher()) {
    return false;
  }
  for (String conformingHost : conformingHostList) {
    if (conformingHost.equalsIgnoreCase(LOCAL_HOST_NAME)) {
      return true;
    }
  }
  return false;
}
项目:bartleby    文件:DBAppenderIntegrationTest.java   
static boolean isConformingHostAndJDK16OrHigher() {
  if(!EnvUtil.isJDK6OrHigher()) {
    return false;
  }
  return EnvUtilForTests.isLocalHostNameInList(CONFORMING_HOST_LIST);
}