本文整理了Java中org.jruby.Ruby.newErrnoENOTDIRError
方法的一些代码示例,展示了Ruby.newErrnoENOTDIRError
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newErrnoENOTDIRError
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newErrnoENOTDIRError
暂无
代码示例来源:origin: org.jruby/jruby-complete
private static String dirFromPath(final String path, final Ruby runtime) throws RaiseException {
String dir = path;
String[] pathParts = RubyFile.splitURI(path);
if (pathParts != null) {
if (pathParts[0].startsWith("file:") && pathParts[1].length() > 0 && pathParts[1].indexOf(".jar!/") == -1) {
dir = pathParts[1];
} else {
throw runtime.newErrnoENOTDIRError(dir);
}
}
return dir;
}
代码示例来源:origin: org.jruby/jruby-core
private static String dirFromPath(final String path, final Ruby runtime) throws RaiseException {
String dir = path;
String[] pathParts = RubyFile.splitURI(path);
if (pathParts != null) {
if (pathParts[0].startsWith("file:") && pathParts[1].length() > 0 && pathParts[1].indexOf(".jar!/") == -1) {
dir = pathParts[1];
} else {
throw runtime.newErrnoENOTDIRError(dir);
}
}
return dir;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static String dirFromPath(final String path, final Ruby runtime) throws RaiseException {
String dir = path;
String[] pathParts = RubyFile.splitURI(path);
if (pathParts != null) {
if (pathParts[0].equals("file:") && pathParts[1].length() > 0 && pathParts[1].indexOf("!/") == -1) {
dir = pathParts[1];
} else {
throw runtime.newErrnoENOTDIRError(dir);
}
}
return dir;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static String dirFromPath(final String path, final Ruby runtime) throws RaiseException {
String dir = path;
String[] pathParts = RubyFile.splitURI(path);
if (pathParts != null) {
if (pathParts[0].equals("file:") && pathParts[1].length() > 0 && pathParts[1].indexOf("!/") == -1) {
dir = pathParts[1];
} else {
throw runtime.newErrnoENOTDIRError(dir);
}
}
return dir;
}
代码示例来源:origin: org.jruby/jruby-complete
private static FileResource getExistingDir(final Ruby runtime, final String path) {
FileResource result = JRubyFile.createResource(runtime, path);
if (result == null || !result.exists()) {
throw runtime.newErrnoENOENTError(path);
}
if (!result.isDirectory()) {
throw runtime.newErrnoENOTDIRError(path);
}
return result;
}
代码示例来源:origin: org.jruby/jruby-core
private static FileResource getExistingDir(final Ruby runtime, final String path) {
FileResource result = JRubyFile.createResource(runtime, path);
if (result == null || !result.exists()) {
throw runtime.newErrnoENOENTError(path);
}
if (!result.isDirectory()) {
throw runtime.newErrnoENOTDIRError(path);
}
return result;
}
代码示例来源:origin: org.jruby/jruby-complete
private static String[] getEntries(ThreadContext context, FileResource dir, String path) {
if (!dir.isDirectory()) {
if (dir.exists()) {
throw context.runtime.newErrnoENOTDIRError(path);
}
throw context.runtime.newErrnoENOENTError(path);
}
if (!dir.canRead()) throw context.runtime.newErrnoEACCESError(path);
String[] list = dir.list();
return list == null ? NO_FILES : list;
}
代码示例来源:origin: org.jruby/jruby-core
private static String[] getEntries(ThreadContext context, FileResource dir, String path) {
if (!dir.isDirectory()) {
if (dir.exists()) {
throw context.runtime.newErrnoENOTDIRError(path);
}
throw context.runtime.newErrnoENOENTError(path);
}
if (!dir.canRead()) throw context.runtime.newErrnoEACCESError(path);
String[] list = dir.list();
return list == null ? NO_FILES : list;
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Similar to getDir, but performs different checks to match rmdir behavior.
* @param runtime
* @param path
* @return
*/
protected static JRubyFile getDirForRmdir(final Ruby runtime, final String path) {
String dir = dirFromPath(path, runtime);
JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), dir);
// Order is important here...File.exists() will return false if the parent
// dir can't be read, so we check permissions first
// no permission
File parentFile = directory.getParentFile();
if (parentFile.exists() && ! parentFile.canWrite()) {
throw runtime.newErrnoEACCESError(path);
}
// Since we transcode we depend on posix to lookup stat stuff since
// java.io.File does not seem to cut it. A failed stat will throw ENOENT.
FileStat stat = runtime.getPosix().stat(directory.toString());
// is not directory
if (!stat.isDirectory()) throw runtime.newErrnoENOTDIRError(path);
return directory;
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Similar to getDir, but performs different checks to match rmdir behavior.
* @param runtime
* @param path
* @return
*/
protected static JRubyFile getDirForRmdir(final Ruby runtime, final String path) {
String dir = dirFromPath(path, runtime);
JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), dir);
// Order is important here...File.exists() will return false if the parent
// dir can't be read, so we check permissions first
// no permission
File parentFile = directory.getParentFile();
if (parentFile.exists() && ! parentFile.canWrite()) {
throw runtime.newErrnoEACCESError(path);
}
// Since we transcode we depend on posix to lookup stat stuff since
// java.io.File does not seem to cut it. A failed stat will throw ENOENT.
FileStat stat = runtime.getPosix().stat(directory.toString());
// is not directory
if (!stat.isDirectory()) throw runtime.newErrnoENOTDIRError(path);
return directory;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Similar to getDir, but performs different checks to match rmdir behavior.
* @param runtime
* @param path
* @param mustExist
* @return
*/
protected static JRubyFile getDirForRmdir(final Ruby runtime, final String path) {
String dir = dirFromPath(path, runtime);
JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), dir);
// Order is important here...File.exists() will return false if the parent
// dir can't be read, so we check permissions first
// no permission
if (directory.getParentFile().exists() &&
!directory.getParentFile().canWrite()) {
throw runtime.newErrnoEACCESError(path);
}
// Since we transcode we depend on posix to lookup stat stuff since
// java.io.File does not seem to cut it. A failed stat will throw ENOENT.
FileStat stat = runtime.getPosix().stat(directory.toString());
// is not directory
if (!stat.isDirectory()) throw runtime.newErrnoENOTDIRError(path);
return directory;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Similar to getDir, but performs different checks to match rmdir behavior.
* @param runtime
* @param path
* @param mustExist
* @return
*/
protected static JRubyFile getDirForRmdir(final Ruby runtime, final String path) {
String dir = dirFromPath(path, runtime);
JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), dir);
// Order is important here...File.exists() will return false if the parent
// dir can't be read, so we check permissions first
// no permission
if (directory.getParentFile().exists() &&
!directory.getParentFile().canWrite()) {
throw runtime.newErrnoEACCESError(path);
}
// Since we transcode we depend on posix to lookup stat stuff since
// java.io.File does not seem to cut it. A failed stat will throw ENOENT.
FileStat stat = runtime.getPosix().stat(directory.toString());
// is not directory
if (!stat.isDirectory()) throw runtime.newErrnoENOTDIRError(path);
return directory;
}
代码示例来源:origin: org.jruby/jruby-complete
/** Returns a Java <code>File</code> object for the specified path. If
* <code>path</code> is not a directory, throws <code>IOError</code>.
*
* @param path path for which to return the <code>File</code> object.
* @param mustExist is true the directory must exist. If false it must not.
*/ // split out - no longer used
protected static FileResource getDir(final Ruby runtime, final String path, final boolean mustExist) {
String dir = dirFromPath(path, runtime);
FileResource result = JRubyFile.createResource(runtime, dir);
if (mustExist && (result == null || !result.exists())) {
throw runtime.newErrnoENOENTError(dir);
}
boolean isDirectory = result.isDirectory();
if (mustExist && !isDirectory) {
throw runtime.newErrnoENOTDIRError(path);
}
if (!mustExist && isDirectory) {
throw runtime.newErrnoEEXISTError(dir);
}
return result;
}
代码示例来源:origin: org.jruby/jruby-core
/** Returns a Java <code>File</code> object for the specified path. If
* <code>path</code> is not a directory, throws <code>IOError</code>.
*
* @param path path for which to return the <code>File</code> object.
* @param mustExist is true the directory must exist. If false it must not.
*/ // split out - no longer used
protected static FileResource getDir(final Ruby runtime, final String path, final boolean mustExist) {
String dir = dirFromPath(path, runtime);
FileResource result = JRubyFile.createResource(runtime, dir);
if (mustExist && (result == null || !result.exists())) {
throw runtime.newErrnoENOENTError(dir);
}
boolean isDirectory = result.isDirectory();
if (mustExist && !isDirectory) {
throw runtime.newErrnoENOTDIRError(path);
}
if (!mustExist && isDirectory) {
throw runtime.newErrnoEEXISTError(dir);
}
return result;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** Returns a Java <code>File</code> object for the specified path. If
* <code>path</code> is not a directory, throws <code>IOError</code>.
*
* @param path path for which to return the <code>File</code> object.
* @param mustExist is true the directory must exist. If false it must not.
* @throws IOError if <code>path</code> is not a directory.
*/
protected static JRubyFile getDir(final Ruby runtime, final String path, final boolean mustExist) {
String dir = dirFromPath(path, runtime);
JRubyFile result = JRubyFile.create(runtime.getCurrentDirectory(), dir);
if (mustExist && !result.exists()) {
throw runtime.newErrnoENOENTError(dir);
}
boolean isDirectory = result.isDirectory();
if (mustExist && !isDirectory) {
throw runtime.newErrnoENOTDIRError(path);
}
if (!mustExist && isDirectory) {
throw runtime.newErrnoEEXISTError(dir);
}
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** Returns a Java <code>File</code> object for the specified path. If
* <code>path</code> is not a directory, throws <code>IOError</code>.
*
* @param path path for which to return the <code>File</code> object.
* @param mustExist is true the directory must exist. If false it must not.
* @throws IOError if <code>path</code> is not a directory.
*/
protected static JRubyFile getDir(final Ruby runtime, final String path, final boolean mustExist) {
String dir = dirFromPath(path, runtime);
JRubyFile result = JRubyFile.create(runtime.getCurrentDirectory(), dir);
if (mustExist && !result.exists()) {
throw runtime.newErrnoENOENTError(dir);
}
boolean isDirectory = result.isDirectory();
if (mustExist && !isDirectory) {
throw runtime.newErrnoENOTDIRError(path);
}
if (!mustExist && isDirectory) {
throw runtime.newErrnoEEXISTError(dir);
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!