热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.jruby.Ruby.newErrnoFromErrno()方法的使用及代码示例

本文整理了Java中org.jruby.Ruby.newErrnoFromErrno方法的一些代码示例,展示了Ruby.newErrnoFromErrno

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

Ruby.newErrnoFromErrno介绍

暂无

代码示例

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

/**
* Java does not give us enough information for specific error conditions
* so we are reduced to divining them through string matches...
*
* TODO: Should ECONNABORTED get thrown earlier in the descriptor itself or is it ok to handle this late?
* TODO: Should we include this into Errno code somewhere do we can use this from other places as well?
*/
public static RaiseException newIOErrorFromException(Ruby runtime, IOException ex) {
Errno errno = errnoFromException(ex);
if (errno == null) throw runtime.newIOError(ex.getLocalizedMessage());
throw runtime.newErrnoFromErrno(errno, ex.getLocalizedMessage());
}

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

/**
* Java does not give us enough information for specific error conditions
* so we are reduced to divining them through string matches...
*
* TODO: Should ECONNABORTED get thrown earlier in the descriptor itself or is it ok to handle this late?
* TODO: Should we include this into Errno code somewhere do we can use this from other places as well?
*/
public static RaiseException newIOErrorFromException(Ruby runtime, IOException ex) {
Errno errno = errnoFromException(ex);
if (errno == null) throw runtime.newIOError(ex.getLocalizedMessage());
throw runtime.newErrnoFromErrno(errno, ex.getLocalizedMessage());
}

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

public static RubyFixnum spawn(ThreadContext context, IRubyObject[] argv) {
Ruby runtime = context.runtime;
long pid = 0;
String[] errmsg = { null };
ExecArg eargp;
IRubyObject fail_str;
eargp = execargNew(context, argv, true);
execargFixup(context, runtime, eargp);
fail_str = eargp.use_shell ? eargp.command_name : eargp.command_name;
PopenExecutor executor = new PopenExecutor();
pid = executor.spawnProcess(context, runtime, eargp, errmsg);
if (pid == -1) {
if (errmsg[0] == null) {
throw runtime.newErrnoFromErrno(executor.errno, fail_str.toString());
}
throw runtime.newErrnoFromErrno(executor.errno, errmsg[0]);
}
return runtime.newFixnum(pid);
}

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

protected static ChannelFD sysopen(Ruby runtime, String fname, int oflags, int perm) {
ChannelFD fd;
Sysopen data = new Sysopen();
data.fname = fname;
data.oflags = oflags;
data.perm = perm;
fd = sysopenInternal(runtime, data);
if (fd == null) {
if (data.errno != null) {
throw runtime.newErrnoFromErrno(data.errno, fname);
} else {
throw runtime.newSystemCallError(fname);
}
}
return fd;
}

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

public void checkCharReadable(ThreadContext context) {
checkClosed();
if ((mode & READABLE) == 0) {
throw runtime.newIOError("not opened for reading");
}
if (wbuf.len != 0) {
if (io_fflush(context) <0) {
throw runtime.newErrnoFromErrno(posix.errno, "error flushing");
}
}
if (tiedIOForWriting != null) {
OpenFile wfptr;
wfptr = tiedIOForWriting.getOpenFileChecked();
if (wfptr.io_fflush(context) <0) {
throw runtime.newErrnoFromErrno(wfptr.posix.errno, wfptr.getPath());
}
}
}

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

protected static ChannelFD sysopen(Ruby runtime, String fname, int oflags, int perm) {
ChannelFD fd;
Sysopen data = new Sysopen();
data.fname = fname;
data.oflags = oflags;
data.perm = perm;
fd = sysopenInternal(runtime, data);
if (fd == null) {
if (data.errno != null) {
throw runtime.newErrnoFromErrno(data.errno, fname);
} else {
throw runtime.newSystemCallError(fname);
}
}
return fd;
}

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

public void checkCharReadable(ThreadContext context) {
checkClosed();
if ((mode & READABLE) == 0) {
throw runtime.newIOError("not opened for reading");
}
if (wbuf.len != 0) {
if (io_fflush(context) <0) {
throw runtime.newErrnoFromErrno(posix.errno, "error flushing");
}
}
if (tiedIOForWriting != null) {
OpenFile wfptr;
wfptr = tiedIOForWriting.getOpenFileChecked();
if (wfptr.io_fflush(context) <0) {
throw runtime.newErrnoFromErrno(wfptr.posix.errno, wfptr.getPath());
}
}
}

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

public void checkReopenSeek(ThreadContext context, Ruby runtime, long pos) {
if (seek(context, pos, PosixShim.SEEK_SET) == -1 && errno() != null) {
throw runtime.newErrnoFromErrno(errno(), getPath());
}
}

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

private void flushBeforeSeek(ThreadContext context) {
boolean locked = lock();
try {
if (io_fflush(context) <0)
throw context.runtime.newErrnoFromErrno(posix.errno, "");
unread(context);
posix.errno = null;
} finally {
if (locked) unlock();
}
}

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

public void checkReopenSeek(ThreadContext context, Ruby runtime, long pos) {
if (seek(context, pos, PosixShim.SEEK_SET) == -1 && errno() != null) {
throw runtime.newErrnoFromErrno(errno(), getPath());
}
}

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

private void flushBeforeSeek(ThreadContext context) {
boolean locked = lock();
try {
if (io_fflush(context) <0)
throw context.runtime.newErrnoFromErrno(posix.errno, "");
unread(context);
posix.errno = null;
} finally {
if (locked) unlock();
}
}

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

public int fread(ThreadContext context, IRubyObject str, int offset, int size) {
int len;
BufreadArg arg = new BufreadArg();
str = EncodingUtils.setStrBuf(context.runtime, str, offset + size);
ByteList strByteList = ((RubyString)str).getByteList();
arg.strPtrBytes = strByteList.unsafeBytes();
arg.strPtr = strByteList.begin() + offset;
arg.len = size;
arg.fptr = this;
// we don't support string locking
// rb_str_locktmp_ensure(str, bufread_call, (VALUE)&arg);
bufreadCall(context, arg);
len = arg.len;
// should be errno
if (len <0) throw context.runtime.newErrnoFromErrno(posix.errno, pathv);
return len;
}

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

public int fread(ThreadContext context, IRubyObject str, int offset, int size) {
int len;
BufreadArg arg = new BufreadArg();
str = EncodingUtils.setStrBuf(context.runtime, str, offset + size);
ByteList strByteList = ((RubyString)str).getByteList();
arg.strPtrBytes = strByteList.unsafeBytes();
arg.strPtr = strByteList.begin() + offset;
arg.len = size;
arg.fptr = this;
// we don't support string locking
// rb_str_locktmp_ensure(str, bufread_call, (VALUE)&arg);
bufreadCall(context, arg);
len = arg.len;
// should be errno
if (len <0) throw context.runtime.newErrnoFromErrno(posix.errno, pathv);
return len;
}

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

private long doSeek(ThreadContext context, long pos, int whence) {
OpenFile fptr;
fptr = getOpenFileChecked();
boolean locked = fptr.lock();
try {
pos = fptr.seek(context, pos, whence);
if (pos <0 && fptr.errno() != null) {
throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
}
} finally {
if (locked) fptr.unlock();
}
return 0;
}

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

private long doSeek(ThreadContext context, long pos, int whence) {
OpenFile fptr;
fptr = getOpenFileChecked();
boolean locked = fptr.lock();
try {
pos = fptr.seek(context, pos, whence);
if (pos <0 && fptr.errno() != null) {
throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
}
} finally {
if (locked) fptr.unlock();
}
return 0;
}

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

@JRubyMethod(name = {"pos", "tell"})
public RubyFixnum pos(ThreadContext context) {
OpenFile fptr = getOpenFileChecked();
boolean locked = fptr.lock();
try {
long pos = fptr.tell(context);
if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
pos -= fptr.rbuf.len;
return context.runtime.newFixnum(pos);
} finally {
if (locked) fptr.unlock();
}
}

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

@JRubyMethod(name = {"pos", "tell"})
public RubyFixnum pos(ThreadContext context) {
OpenFile fptr = getOpenFileChecked();
boolean locked = fptr.lock();
try {
long pos = fptr.tell(context);
if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
pos -= fptr.rbuf.len;
return context.runtime.newFixnum(pos);
} finally {
if (locked) fptr.unlock();
}
}

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

@JRubyMethod(name = "pos=", required = 1)
public RubyFixnum pos_set(ThreadContext context, IRubyObject offset) {
OpenFile fptr;
long pos;
pos = offset.convertToInteger().getLongValue();
fptr = getOpenFileChecked();
boolean locked = fptr.lock();
try {
pos = fptr.seek(context, pos, PosixShim.SEEK_SET);
if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
} finally {
if (locked) fptr.unlock();
}
return context.runtime.newFixnum(pos);
}

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

@JRubyMethod(name = "pos=", required = 1)
public RubyFixnum pos_set(ThreadContext context, IRubyObject offset) {
OpenFile fptr;
long pos;
pos = offset.convertToInteger().getLongValue();
fptr = getOpenFileChecked();
boolean locked = fptr.lock();
try {
pos = fptr.seek(context, pos, PosixShim.SEEK_SET);
if (pos == -1 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
} finally {
if (locked) fptr.unlock();
}
return context.runtime.newFixnum(pos);
}

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

@JRubyMethod(required = 1)
public IRubyObject truncate(ThreadContext context, IRubyObject len) {
Ruby runtime = context.runtime;
OpenFile fptr;
long pos;
pos = RubyNumeric.num2int(len);
fptr = getOpenFileChecked();
if (!fptr.isWritable()) {
throw runtime.newIOError("not opened for writing");
}
flushRaw(context, false);
if (pos <0) {
throw runtime.newErrnoEINVALError(openFile.getPath());
}
if (fptr.posix.ftruncate(fptr.fd(), pos) <0) {
throw runtime.newErrnoFromErrno(fptr.posix.errno, fptr.getPath());
}
return RubyFixnum.zero(runtime);
}

推荐阅读
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 闭包一直是Java社区中争论不断的话题,很多语言都支持闭包这个语言特性,闭包定义了一个依赖于外部环境的自由变量的函数,这个函数能够访问外部环境的变量。本文以JavaScript的一个闭包为例,介绍了闭包的定义和特性。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • baresip android编译、运行教程1语音通话
    本文介绍了如何在安卓平台上编译和运行baresip android,包括下载相关的sdk和ndk,修改ndk路径和输出目录,以及创建一个c++的安卓工程并将目录考到cpp下。详细步骤可参考给出的链接和文档。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
author-avatar
粪想升或_519
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有