本文整理了Java中org.jruby.Ruby.newErrnoFromLastPOSIXErrno
方法的一些代码示例,展示了Ruby.newErrnoFromLastPOSIXErrno
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newErrnoFromLastPOSIXErrno
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newErrnoFromLastPOSIXErrno
暂无
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 1, meta = true)
public static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path) {
Ruby runtime = context.runtime;
if (Platform.IS_WINDOWS) {
// readlink is not available on Windows. See above and jruby/jruby#3287.
// TODO: MRI does not implement readlink on Windows, but perhaps we could?
throw runtime.newNotImplementedError("readlink");
}
JRubyFile link = file(path);
try {
String realPath = runtime.getPosix().readlink(link.toString());
if (realPath == null) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
return RubyString.newString(runtime, realPath, runtime.getEncodingService().getFileSystemEncoding());
} catch (IOException e) {
throw runtime.newIOError(e.getMessage());
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, meta = true)
public static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path) {
Ruby runtime = context.runtime;
JRubyFile link = file(path);
try {
String realPath = runtime.getPosix().readlink(link.toString());
if (!RubyFileTest.exist_p(recv, path).isTrue()) {
throw runtime.newErrnoENOENTError(path.toString());
}
if (!RubyFileTest.symlink_p(recv, path).isTrue()) {
// Can not check earlier, File.exist? might return false yet the symlink be there
if (!RubyFileTest.exist_p(recv, path).isTrue()) {
throw runtime.newErrnoENOENTError(path.toString());
}
throw runtime.newErrnoEINVALError(path.toString());
}
if (realPath == null) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
return runtime.newString(realPath);
} catch (IOException e) {
throw runtime.newIOError(e.getMessage());
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, meta = true)
public static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path) {
Ruby runtime = context.runtime;
JRubyFile link = file(path);
try {
String realPath = runtime.getPosix().readlink(link.toString());
if (!RubyFileTest.exist_p(recv, path).isTrue()) {
throw runtime.newErrnoENOENTError(path.toString());
}
if (!RubyFileTest.symlink_p(recv, path).isTrue()) {
// Can not check earlier, File.exist? might return false yet the symlink be there
if (!RubyFileTest.exist_p(recv, path).isTrue()) {
throw runtime.newErrnoENOENTError(path.toString());
}
throw runtime.newErrnoEINVALError(path.toString());
}
if (realPath == null) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
return runtime.newString(realPath);
} catch (IOException e) {
throw runtime.newIOError(e.getMessage());
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static IRubyObject times(Ruby runtime) {
Times tms = runtime.getPosix().times();
if (tms == null) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
long hz = runtime.getPosix().sysconf(Sysconf._SC_CLK_TCK);
if (hz == -1) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
return RubyStruct.newStruct(runtime.getTmsStruct(),
new IRubyObject[] {
runtime.newFloat((double) tms.utime() / (double) hz),
runtime.newFloat((double) tms.stime() / (double) hz),
runtime.newFloat((double) tms.cutime() / (double) hz),
runtime.newFloat((double) tms.cstime() / (double) hz)
},
Block.NULL_BLOCK);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static IRubyObject times(Ruby runtime) {
Times tms = runtime.getPosix().times();
if (tms == null) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
long hz = runtime.getPosix().sysconf(Sysconf._SC_CLK_TCK);
if (hz == -1) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
return RubyStruct.newStruct(runtime.getTmsStruct(),
new IRubyObject[] {
runtime.newFloat((double) tms.utime() / (double) hz),
runtime.newFloat((double) tms.stime() / (double) hz),
runtime.newFloat((double) tms.cutime() / (double) hz),
runtime.newFloat((double) tms.cstime() / (double) hz)
},
Block.NULL_BLOCK);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 1, rest = true, meta = true)
public static IRubyObject lchmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchmod(file.toString(), (int) mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 1, rest = true, meta = true)
public static IRubyObject lchmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchmod(file.toString(), (int) mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 1, meta = true)
public static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path) {
Ruby runtime = context.runtime;
if (Platform.IS_WINDOWS) {
// readlink is not available on Windows. See above and jruby/jruby#3287.
// TODO: MRI does not implement readlink on Windows, but perhaps we could?
throw runtime.newNotImplementedError("readlink");
}
JRubyFile link = file(path);
try {
String realPath = runtime.getPosix().readlink(link.toString());
if (realPath == null) {
throw runtime.newErrnoFromLastPOSIXErrno();
}
return RubyString.newString(runtime, realPath, runtime.getEncodingService().getFileSystemEncoding());
} catch (IOException e) {
throw runtime.newIOError(e.getMessage());
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, rest = true, meta = true)
public static IRubyObject lchmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchmod(file.toString(), (int)mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, rest = true, meta = true)
public static IRubyObject lchmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchmod(file.toString(), (int)mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject lchown(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int owner = !args[0].isNil() ? RubyNumeric.num2int(args[0]) : -1;
int group = !args[1].isNil() ? RubyNumeric.num2int(args[1]) : -1;
int count = 0;
for (int i = 2; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchown(file.toString(), owner, group)) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject lchown(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int owner = !args[0].isNil() ? RubyNumeric.num2int(args[0]) : -1;
int group = !args[1].isNil() ? RubyNumeric.num2int(args[1]) : -1;
int count = 0;
for (int i = 2; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchown(file.toString(), owner, group)) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject lchown(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int owner = !args[0].isNil() ? RubyNumeric.num2int(args[0]) : -1;
int group = !args[1].isNil() ? RubyNumeric.num2int(args[1]) : -1;
int count = 0;
for (int i = 2; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchown(file.toString(), owner, group)) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject lchown(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int owner = !args[0].isNil() ? RubyNumeric.num2int(args[0]) : -1;
int group = !args[1].isNil() ? RubyNumeric.num2int(args[1]) : -1;
int count = 0;
for (int i = 2; i < args.length; i++) {
JRubyFile file = file(args[i]);
if (0 != runtime.getPosix().lchown(file.toString(), owner, group)) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject chmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile filename = file(args[i]);
if (!filename.exists()) {
throw runtime.newErrnoENOENTError(filename.toString());
}
if (0 != runtime.getPosix().chmod(filename.getAbsolutePath(), (int) mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject chmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile filename = file(args[i]);
if (!filename.exists()) {
throw runtime.newErrnoENOENTError(filename.toString());
}
if (0 != runtime.getPosix().chmod(filename.getAbsolutePath(), (int) mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject chmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile filename = file(args[i]);
if (!filename.exists()) {
throw runtime.newErrnoENOENTError(filename.toString());
}
if (0 != runtime.getPosix().chmod(filename.getAbsolutePath(), (int)mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject chmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
RubyInteger mode = args[0].convertToInteger();
for (int i = 1; i < args.length; i++) {
JRubyFile filename = file(args[i]);
if (!filename.exists()) {
throw runtime.newErrnoENOENTError(filename.toString());
}
if (0 != runtime.getPosix().chmod(filename.getAbsolutePath(), (int)mode.getLongValue())) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 3, rest = true, meta = true)
public static IRubyObject chown(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
int owner = -1;
if (!args[0].isNil()) {
owner = RubyNumeric.num2int(args[0]);
}
int group = -1;
if (!args[1].isNil()) {
group = RubyNumeric.num2int(args[1]);
}
for (int i = 2; i < args.length; i++) {
JRubyFile filename = file(args[i]);
if (!filename.exists()) {
throw runtime.newErrnoENOENTError(filename.toString());
}
if (0 != runtime.getPosix().chown(filename.getAbsolutePath(), owner, group)) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 2, rest = true, meta = true)
public static IRubyObject chown(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
int count = 0;
int owner = -1;
if (!args[0].isNil()) {
owner = RubyNumeric.num2int(args[0]);
}
int group = -1;
if (!args[1].isNil()) {
group = RubyNumeric.num2int(args[1]);
}
for (int i = 2; i < args.length; i++) {
JRubyFile filename = file(args[i]);
if (!filename.exists()) {
throw runtime.newErrnoENOENTError(filename.toString());
}
if (0 != runtime.getPosix().chown(filename.getAbsolutePath(), owner, group)) {
throw runtime.newErrnoFromLastPOSIXErrno();
} else {
count++;
}
}
return runtime.newFixnum(count);
}
内容来源于网络,如有侵权,请联系作者删除!