@Override public String canonicalPath() { // Seems like for Ruby absolute path implies resolving system links, // so canonicalization is in order. try { return file.getCanonicalPath(); } catch (IOException ioError) { // I guess absolute path is next best thing? return file.getAbsolutePath(); } }
@Override public File getCanonicalFile() throws IOException { return new JRubyFile(getCanonicalPath()); }
@Override public String canonicalPath() { // Seems like for Ruby absolute path implies resolving system links, // so canonicalization is in order. try { return file.getCanonicalPath(); } catch (IOException ioError) { // I guess absolute path is next best thing? return file.getAbsolutePath(); } }
@Override public File getCanonicalFile() throws IOException { return new JRubyFile(getCanonicalPath()); }
@Override public File getCanonicalFile() throws IOException { return new JRubyFile(getCanonicalPath()); }
@Override public File getCanonicalFile() throws IOException { return new JRubyFile(getCanonicalPath()); }
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; } }
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; } }
String before = filename.substring(6, filename.indexOf("!")); if (canonicalize) { classPath = new JRubyFile(before + filename.substring(filename.indexOf("!")+1)).getCanonicalPath().toString(); } else { classPath = new JRubyFile(before + filename.substring(filename.indexOf("!")+1)).toString(); try { if (canonicalize) { classPath = new JRubyFile(filename).getCanonicalPath().toString(); } else { classPath = new JRubyFile(filename).toString(); try { if (canonicalize) { parentPath = new JRubyFile(parent).getCanonicalPath().toString(); } else { parentPath = new JRubyFile(parent).toString();
try { if (canonicalize) { classPath = new JRubyFile(before + filename.substring(idx + 1)).getCanonicalPath(); } else { classPath = new JRubyFile(before + filename.substring(idx + 1)).toString(); try { if (canonicalize) { classPath = new JRubyFile(filename).getCanonicalPath(); } else { classPath = new JRubyFile(filename).toString(); try { if (canonicalize) { parentPath = new JRubyFile(parent).getCanonicalPath(); } else { parentPath = new JRubyFile(parent).toString();
try { if (canonicalize) { classPath = new JRubyFile(before + filename.substring(idx + 1)).getCanonicalPath(); } else { classPath = new JRubyFile(before + filename.substring(idx + 1)).toString(); try { if (canonicalize) { classPath = new JRubyFile(filename).getCanonicalPath(); } else { classPath = new JRubyFile(filename).toString(); try { if (canonicalize) { parentPath = new JRubyFile(parent).getCanonicalPath(); } else { parentPath = new JRubyFile(parent).toString();
String before = filename.substring(6, filename.indexOf("!")); if (canonicalize) { classPath = new JRubyFile(before + filename.substring(filename.indexOf("!")+1)).getCanonicalPath().toString(); } else { classPath = new JRubyFile(before + filename.substring(filename.indexOf("!")+1)).toString(); try { if (canonicalize) { classPath = new JRubyFile(filename).getCanonicalPath().toString(); } else { classPath = new JRubyFile(filename).toString(); try { if (canonicalize) { parentPath = new JRubyFile(parent).getCanonicalPath().toString(); } else { parentPath = new JRubyFile(parent).toString();
@JRubyMethod(name = "identical?", required = 2, module = true) public static IRubyObject identical_p(IRubyObject recv, IRubyObject filename1, IRubyObject filename2) { Ruby runtime = recv.getRuntime(); JRubyFile file1 = file(filename1); JRubyFile file2 = file(filename2); if (Platform.IS_WINDOWS || !runtime.getPosix().isNative()) { // posix stat uses inodes to determine indentity, and windows has no inodes // (they are always zero), so we use canonical paths instead. (JRUBY-5726) // If we can't load a native POSIX, use this same logic. (JRUBY-6982) try { return runtime.newBoolean(file1.exists() && file2.exists() && file1.getCanonicalPath().equals(file2.getCanonicalPath())); } catch (IOException e) { // this is indicative of something really wrong, but for now... return runtime.getFalse(); } } return runtime.newBoolean(file1.exists() && file2.exists() && runtime.getPosix().stat(file1.getAbsolutePath()).isIdentical(runtime.getPosix().stat(file2.getAbsolutePath()))); }
realPath = dir.getCanonicalPath(); } catch (IOException e) { realPath = dir.getAbsolutePath();
realPath = dir.getCanonicalPath(); } catch (IOException e) { realPath = dir.getAbsolutePath();