本文整理了Java中org.jruby.Ruby.getCurrentDirectory
方法的一些代码示例,展示了Ruby.getCurrentDirectory
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getCurrentDirectory
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getCurrentDirectory
暂无
代码示例来源:origin: org.jruby/jruby-complete
public File getCurrentWorkingDirectory() {
return new File(runtime.getCurrentDirectory());
}
代码示例来源:origin: org.jruby/jruby-core
public File getCurrentWorkingDirectory() {
return new File(runtime.getCurrentDirectory());
}
代码示例来源:origin: org.jruby/jruby-core
public static String changeDirInsideJar(final Ruby runtime, final String arg) {
// only if inside a jar and spawning org.jruby.Main we change to the current directory inside the jar
if (runtime.getCurrentDirectory().startsWith("uri:classloader:") && arg.contains("org.jruby.Main")) {
return StringSupport.replaceFirst(arg, "org.jruby.Main", "org.jruby.Main -C " + runtime.getCurrentDirectory()).toString();
}
return null;
}
代码示例来源:origin: org.jruby/jruby-complete
public static String changeDirInsideJar(final Ruby runtime, final String arg) {
// only if inside a jar and spawning org.jruby.Main we change to the current directory inside the jar
if (runtime.getCurrentDirectory().startsWith("uri:classloader:") && arg.contains("org.jruby.Main")) {
return StringSupport.replaceFirst(arg, "org.jruby.Main", "org.jruby.Main -C " + runtime.getCurrentDirectory()).toString();
}
return null;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static String getCWD(Ruby runtime) {
try {
return new org.jruby.util.NormalizedFile(runtime.getCurrentDirectory()).getCanonicalPath();
} catch (Exception e) {
return runtime.getCurrentDirectory();
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static String getCWD(Ruby runtime) {
try {
return new org.jruby.util.NormalizedFile(runtime.getCurrentDirectory()).getCanonicalPath();
} catch (Exception e) {
return runtime.getCurrentDirectory();
}
}
代码示例来源:origin: org.jruby/jruby-core
public static FileResource createResourceAsFile(Ruby runtime, String pathname) {
return createResource(runtime, runtime.getCurrentDirectory(), pathname, true);
}
代码示例来源:origin: org.jruby/jruby-complete
public static FileResource createResourceAsFile(Ruby runtime, String pathname) {
return createResource(runtime, runtime.getCurrentDirectory(), pathname, true);
}
代码示例来源:origin: org.jruby/jruby-complete
public static FileResource createResource(Ruby runtime, String pathname) {
return createResource(runtime, runtime.getCurrentDirectory(), pathname, false);
}
代码示例来源:origin: org.jruby/jruby-complete
private static File tryFile(Ruby runtime, String fdir, String fname) {
File pathFile;
if (fdir == null) {
pathFile = new File(fname);
} else {
pathFile = new File(fdir, fname);
}
if (!pathFile.isAbsolute()) {
pathFile = new File(runtime.getCurrentDirectory(), pathFile.getPath());
}
log(runtime, "Trying file " + pathFile);
if (pathFile.exists()) return pathFile;
return null;
}
代码示例来源:origin: org.jruby/jruby-core
private static File tryFile(Ruby runtime, String fdir, String fname) {
File pathFile;
if (fdir == null) {
pathFile = new File(fname);
} else {
pathFile = new File(fdir, fname);
}
if (!pathFile.isAbsolute()) {
pathFile = new File(runtime.getCurrentDirectory(), pathFile.getPath());
}
log(runtime, "Trying file " + pathFile);
if (pathFile.exists()) return pathFile;
return null;
}
代码示例来源:origin: org.jruby/jruby-complete
private static String getCWD(Ruby runtime) {
final String cwd = runtime.getCurrentDirectory();
// ^(uri|jar|file|classpath):([^:]*:)?//?.*
if (cwd.startsWith("uri:") || cwd.startsWith("jar:") || cwd.startsWith("file:")) {
// "classpath:" mapped into "uri:classloader:"
return cwd;
}
try { // NOTE: likely not necessary as we already canonicalized while setting?
return new JRubyFile(cwd).getCanonicalPath();
}
catch (IOException e) {
return cwd;
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static List<String> entriesIntoADirectory(Ruby runtime, String path) {
final JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), path);
List<String> fileList = getContents(directory);
fileList.add(0, ".");
fileList.add(1, "..");
return fileList;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static List<String> entriesIntoADirectory(Ruby runtime, String path) {
final JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), path);
List<String> fileList = getContents(directory);
fileList.add(0, ".");
fileList.add(1, "..");
return fileList;
}
代码示例来源:origin: org.jruby/jruby-core
@Deprecated // no longer used
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
try {
ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
Stream stream = fdopen(runtime, descriptor, modes);
return stream;
} catch (ResourceException resourceException) {
throw resourceException.newRaiseException(runtime);
}
}
代码示例来源:origin: org.jruby/jruby-complete
@Deprecated // no longer used
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
try {
ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
Stream stream = fdopen(runtime, descriptor, modes);
return stream;
} catch (ResourceException resourceException) {
throw resourceException.newRaiseException(runtime);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
Stream stream = fdopen(runtime, descriptor, modes);
return stream;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
Stream stream = fdopen(runtime, descriptor, modes);
return stream;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private void setup(String filename, boolean lstat) {
if (Platform.IS_WINDOWS && filename.length() == 2
&& filename.charAt(1) == ':' && Character.isLetter(filename.charAt(0))) {
filename += "/";
}
file = JRubyFile.createResource(getRuntime().getCurrentDirectory(), filename);
if (!file.exists()) {
throw getRuntime().newErrnoENOENTError("No such file or directory - " + filename);
}
POSIX posix = getRuntime().getPosix();
stat = lstat ? file.lstat(posix) : file.stat(posix);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static RubyFileStat getFileStat(ThreadContext context, IRubyObject filename) {
Ruby runtime = context.runtime;
RubyFileStat stat = null;
if (!(filename instanceof RubyFile)) {
RubyString path = get_path(context, filename);
JRubyFile file = JRubyFile.create(runtime.getCurrentDirectory(), path.getUnicodeValue());
if (file.exists()) {
stat = runtime.newFileStat(file.getPath(), false);
}
} else {
stat = (RubyFileStat) ((RubyFile) filename).stat(context);
}
return stat;
}
内容来源于网络,如有侵权,请联系作者删除!