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

x33g5p2x  于2022-01-29 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(177)

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

Ruby.getCurrentDirectory介绍

暂无

代码示例

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

  1. public File getCurrentWorkingDirectory() {
  2. return new File(runtime.getCurrentDirectory());
  3. }

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

  1. public File getCurrentWorkingDirectory() {
  2. return new File(runtime.getCurrentDirectory());
  3. }

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

  1. public static String changeDirInsideJar(final Ruby runtime, final String arg) {
  2. // only if inside a jar and spawning org.jruby.Main we change to the current directory inside the jar
  3. if (runtime.getCurrentDirectory().startsWith("uri:classloader:") && arg.contains("org.jruby.Main")) {
  4. return StringSupport.replaceFirst(arg, "org.jruby.Main", "org.jruby.Main -C " + runtime.getCurrentDirectory()).toString();
  5. }
  6. return null;
  7. }

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

  1. public static String changeDirInsideJar(final Ruby runtime, final String arg) {
  2. // only if inside a jar and spawning org.jruby.Main we change to the current directory inside the jar
  3. if (runtime.getCurrentDirectory().startsWith("uri:classloader:") && arg.contains("org.jruby.Main")) {
  4. return StringSupport.replaceFirst(arg, "org.jruby.Main", "org.jruby.Main -C " + runtime.getCurrentDirectory()).toString();
  5. }
  6. return null;
  7. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. private static String getCWD(Ruby runtime) {
  2. try {
  3. return new org.jruby.util.NormalizedFile(runtime.getCurrentDirectory()).getCanonicalPath();
  4. } catch (Exception e) {
  5. return runtime.getCurrentDirectory();
  6. }
  7. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. private static String getCWD(Ruby runtime) {
  2. try {
  3. return new org.jruby.util.NormalizedFile(runtime.getCurrentDirectory()).getCanonicalPath();
  4. } catch (Exception e) {
  5. return runtime.getCurrentDirectory();
  6. }
  7. }

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

  1. public static FileResource createResourceAsFile(Ruby runtime, String pathname) {
  2. return createResource(runtime, runtime.getCurrentDirectory(), pathname, true);
  3. }

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

  1. public static FileResource createResourceAsFile(Ruby runtime, String pathname) {
  2. return createResource(runtime, runtime.getCurrentDirectory(), pathname, true);
  3. }

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

  1. public static FileResource createResource(Ruby runtime, String pathname) {
  2. return createResource(runtime, runtime.getCurrentDirectory(), pathname, false);
  3. }

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

  1. private static File tryFile(Ruby runtime, String fdir, String fname) {
  2. File pathFile;
  3. if (fdir == null) {
  4. pathFile = new File(fname);
  5. } else {
  6. pathFile = new File(fdir, fname);
  7. }
  8. if (!pathFile.isAbsolute()) {
  9. pathFile = new File(runtime.getCurrentDirectory(), pathFile.getPath());
  10. }
  11. log(runtime, "Trying file " + pathFile);
  12. if (pathFile.exists()) return pathFile;
  13. return null;
  14. }

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

  1. private static File tryFile(Ruby runtime, String fdir, String fname) {
  2. File pathFile;
  3. if (fdir == null) {
  4. pathFile = new File(fname);
  5. } else {
  6. pathFile = new File(fdir, fname);
  7. }
  8. if (!pathFile.isAbsolute()) {
  9. pathFile = new File(runtime.getCurrentDirectory(), pathFile.getPath());
  10. }
  11. log(runtime, "Trying file " + pathFile);
  12. if (pathFile.exists()) return pathFile;
  13. return null;
  14. }

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

  1. private static String getCWD(Ruby runtime) {
  2. final String cwd = runtime.getCurrentDirectory();
  3. // ^(uri|jar|file|classpath):([^:]*:)?//?.*
  4. if (cwd.startsWith("uri:") || cwd.startsWith("jar:") || cwd.startsWith("file:")) {
  5. // "classpath:" mapped into "uri:classloader:"
  6. return cwd;
  7. }
  8. try { // NOTE: likely not necessary as we already canonicalized while setting?
  9. return new JRubyFile(cwd).getCanonicalPath();
  10. }
  11. catch (IOException e) {
  12. return cwd;
  13. }
  14. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. private static List<String> entriesIntoADirectory(Ruby runtime, String path) {
  2. final JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), path);
  3. List<String> fileList = getContents(directory);
  4. fileList.add(0, ".");
  5. fileList.add(1, "..");
  6. return fileList;
  7. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. private static List<String> entriesIntoADirectory(Ruby runtime, String path) {
  2. final JRubyFile directory = JRubyFile.create(runtime.getCurrentDirectory(), path);
  3. List<String> fileList = getContents(directory);
  4. fileList.add(0, ".");
  5. fileList.add(1, "..");
  6. return fileList;
  7. }

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

  1. @Deprecated // no longer used
  2. public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  3. try {
  4. ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
  5. Stream stream = fdopen(runtime, descriptor, modes);
  6. return stream;
  7. } catch (ResourceException resourceException) {
  8. throw resourceException.newRaiseException(runtime);
  9. }
  10. }

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

  1. @Deprecated // no longer used
  2. public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  3. try {
  4. ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
  5. Stream stream = fdopen(runtime, descriptor, modes);
  6. return stream;
  7. } catch (ResourceException resourceException) {
  8. throw resourceException.newRaiseException(runtime);
  9. }
  10. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  2. ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
  3. Stream stream = fdopen(runtime, descriptor, modes);
  4. return stream;
  5. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  2. ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
  3. Stream stream = fdopen(runtime, descriptor, modes);
  4. return stream;
  5. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. private void setup(String filename, boolean lstat) {
  2. if (Platform.IS_WINDOWS && filename.length() == 2
  3. && filename.charAt(1) == ':' && Character.isLetter(filename.charAt(0))) {
  4. filename += "/";
  5. }
  6. file = JRubyFile.createResource(getRuntime().getCurrentDirectory(), filename);
  7. if (!file.exists()) {
  8. throw getRuntime().newErrnoENOENTError("No such file or directory - " + filename);
  9. }
  10. POSIX posix = getRuntime().getPosix();
  11. stat = lstat ? file.lstat(posix) : file.stat(posix);
  12. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. private static RubyFileStat getFileStat(ThreadContext context, IRubyObject filename) {
  2. Ruby runtime = context.runtime;
  3. RubyFileStat stat = null;
  4. if (!(filename instanceof RubyFile)) {
  5. RubyString path = get_path(context, filename);
  6. JRubyFile file = JRubyFile.create(runtime.getCurrentDirectory(), path.getUnicodeValue());
  7. if (file.exists()) {
  8. stat = runtime.newFileStat(file.getPath(), false);
  9. }
  10. } else {
  11. stat = (RubyFileStat) ((RubyFile) filename).stat(context);
  12. }
  13. return stat;
  14. }

相关文章

Ruby类方法