com.sun.jna.Native.setLastError()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(160)

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

Native.setLastError介绍

[英]Set the OS last error code. Whether the setting is per-thread or global depends on the underlying OS.
[中]设置操作系统最后一个错误代码。设置是按线程还是全局取决于底层操作系统。

代码示例

代码示例来源:origin: io.dvlopt/linux-common

/**
   * Set the value of <code>errno</code>.
   *
   * @param value The new value of errno.
   *
   * @see getErrno
   */
  public static void setErrno( int value ) {

    Native.setLastError( value ) ;
  }
}

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

public void setLastError(int error) {
  Native.setLastError(error);
}

代码示例来源:origin: xyz.cofe/j-libc

public static void setErrno(int n){
  Native.setLastError(n);
}

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

protected static void rb_sys_fail(Ruby runtime, String message) {
  int n = Native.getLastError();
  Native.setLastError(0);
  IRubyObject arg = (message != null) ? runtime.newString(message) : runtime.getNil();
  RubyClass instance = runtime.getErrno(n);
  if(instance == null) {
    instance = runtime.getSystemCallError();
    throw new RaiseException((RubyException)(instance.newInstance(runtime.getCurrentContext(), new IRubyObject[]{arg, runtime.newFixnum(n)}, Block.NULL_BLOCK)));
  } else {
    throw new RaiseException((RubyException)(instance.newInstance(runtime.getCurrentContext(), new IRubyObject[]{arg}, Block.NULL_BLOCK)));
  }
}

相关文章

微信公众号

最新文章

更多

Native类方法