jnr.posix.POSIX.setenv()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中jnr.posix.POSIX.setenv()方法的一些代码示例,展示了POSIX.setenv()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POSIX.setenv()方法的具体详情如下:
包路径:jnr.posix.POSIX
类名称:POSIX
方法名:setenv

POSIX.setenv介绍

暂无

代码示例

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

public int setenv(String envName, String envValue, int overwrite) {
  try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

public int setenv(String envName, String envValue, int overwrite) {
  return posix().setenv(envName, envValue, overwrite);
}

代码示例来源:origin: com.cloudbees.util/jnr-unixsocket-nodep

public int setenv(String envName, String envValue, int overwrite) {
  try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

public int setenv(String envName, String envValue, int overwrite) {
  try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: com.github.jnr/jnr-posix

public int setenv(String envName, String envValue, int overwrite) {
  return posix().setenv(envName, envValue, overwrite);
}

代码示例来源:origin: com.github.jnr/jnr-posix

public int setenv(String envName, String envValue, int overwrite) {
  try { return posix.setenv(envName, envValue, overwrite); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); }
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

public int setenv(String envName, String envValue, int overwrite) {
  return posix().setenv(envName, envValue, overwrite);
}

代码示例来源:origin: com.cloudbees.util/jnr-unixsocket-nodep

public int setenv(String envName, String envValue, int overwrite) {
  return posix().setenv(envName, envValue, overwrite);
}

代码示例来源:origin: jerlang/jerlang

/**
 * Sets a new Value for the environment variable VarName.
 *
 * http://www.erlang.org/doc/man/os.html#putenv-2
 */
public static Term putenv_2(Str varName, Str value) {
  posix.setenv(varName.string(), value.string(), 1);
  return Boolean.am_true;
}

代码示例来源:origin: org.jruby/jruby-complete

private IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, final IRubyObject value) {
  if (!isStringLike(key)) {
    throw context.runtime.newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  RubyString keyAsStr = key.convertToString();
  if (!isCaseSensitive()) key = keyAsStr = getCorrectKey(keyAsStr);
  if (value == context.nil) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  if (!isStringLike(value)) {
    throw context.runtime.newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  RubyString valueAsStr = normalizeEnvString(context, keyAsStr, value.convertToString());
  if (updateRealENV) {
    final POSIX posix = context.runtime.getPosix();
    final String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == context.nil) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      final String valueAsJava = valueAsStr.asJavaString();
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsJava, 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

代码示例来源:origin: org.jruby/jruby-core

private IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, final IRubyObject value) {
  if (!isStringLike(key)) {
    throw context.runtime.newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  RubyString keyAsStr = key.convertToString();
  if (!isCaseSensitive()) key = keyAsStr = getCorrectKey(keyAsStr);
  if (value == context.nil) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  if (!isStringLike(value)) {
    throw context.runtime.newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  RubyString valueAsStr = normalizeEnvString(context, keyAsStr, value.convertToString());
  if (updateRealENV) {
    final POSIX posix = context.runtime.getPosix();
    final String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == context.nil) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      final String valueAsJava = valueAsStr.asJavaString();
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsJava, 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

protected IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, IRubyObject value, boolean caseSensitive) {
  if (!key.respondsTo("to_str")) {
    throw getRuntime().newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  if (!value.respondsTo("to_str") && !value.isNil()) {
    throw getRuntime().newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  if (! caseSensitive) {
    key = getCorrectKey(key, context);
  }
  if (value.isNil()) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  IRubyObject keyAsStr = normalizeEnvString(Helpers.invoke(context, key, "to_str"));
  IRubyObject valueAsStr = value.isNil() ? getRuntime().getNil() :
      normalizeEnvString(Helpers.invoke(context, value, "to_str"));
  if (updateRealENV) {
    POSIX posix = getRuntime().getPosix();
    String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == getRuntime().getNil()) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsStr.asJavaString(), 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected IRubyObject case_aware_op_aset(ThreadContext context, IRubyObject key, IRubyObject value, boolean caseSensitive) {
  if (!key.respondsTo("to_str")) {
    throw getRuntime().newTypeError("can't convert " + key.getMetaClass() + " into String");
  }
  if (!value.respondsTo("to_str") && !value.isNil()) {
    throw getRuntime().newTypeError("can't convert " + value.getMetaClass() + " into String");
  }
  if (! caseSensitive) {
    key = getCorrectKey(key, context);
  }
  if (value.isNil()) {
    return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK);
  }
  IRubyObject keyAsStr = normalizeEnvString(Helpers.invoke(context, key, "to_str"));
  IRubyObject valueAsStr = value.isNil() ? getRuntime().getNil() :
      normalizeEnvString(Helpers.invoke(context, value, "to_str"));
  if (updateRealENV) {
    POSIX posix = getRuntime().getPosix();
    String keyAsJava = keyAsStr.asJavaString();
    // libc (un)setenv is not reentrant, so we need to synchronize across the entire JVM (JRUBY-5933)
    if (valueAsStr == getRuntime().getNil()) {
      synchronized (Object.class) { posix.unsetenv(keyAsJava); }
    } else {
      synchronized (Object.class) { posix.setenv(keyAsJava, valueAsStr.asJavaString(), 1); }
    }
  }
  return super.op_aset(context, keyAsStr, valueAsStr);
}

相关文章

POSIX类方法