protected RegularFileResource(POSIX posix, String filename) { this.file = new JRubyFile(filename); this.filePath = filename; this.posix = posix; }
protected RegularFileResource(POSIX posix, String filename) { this.file = new JRubyFile(filename); this.filePath = filename; this.posix = posix; }
public static File createTempFile(String prefix, String suffix) throws IOException { return new JRubyFile(File.createTempFile(prefix, suffix)); }
private static JRubyFile createNoUnicodeConversion(String cwd, String pathname, File path) { // File and company do not seem to recognize bare \ and / on Windows as absolute. Cheat! if (path.isAbsolute() || Platform.IS_WINDOWS && (pathname.startsWith("/") || pathname.startsWith("\\"))) { return new JRubyFile(path); } if (cwd != null && cwd.startsWith("uri:") && !pathname.startsWith("uri:") && !pathname.contains("!/")) { return new JRubyFile(cwd + '/' + pathname); } path = new File(cwd, pathname); if (!path.isAbsolute()) { throw new IllegalArgumentException("Neither current working directory ("+cwd+") nor pathname ("+pathname+") led to an absolute path"); } return new JRubyFile(path); }
@Override public File getParentFile() { String parent = getParent(); if (parent == null) return this; return new JRubyFile(parent); }
public static File[] listRoots() { File[] roots = File.listRoots(); JRubyFile[] smartRoots = new JRubyFile[roots.length]; for(int i = 0, j = roots.length; i < j; i++) { smartRoots[i] = new JRubyFile(roots[i].getPath()); } return smartRoots; }
@Override public File getParentFile() { String par = getParent(); if (par == null) { return this; } else { return new JRubyFile(par); } }
public static File[] listRoots() { File[] roots = File.listRoots(); JRubyFile[] smartRoots = new JRubyFile[roots.length]; for(int i = 0, j = roots.length; i < j; i++) { smartRoots[i] = new JRubyFile(roots[i].getPath()); } return smartRoots; }
@Override public File getParentFile() { String parent = getParent(); if (parent == null) return this; return new JRubyFile(parent); }
public static File[] listRoots() { File[] roots = File.listRoots(); JRubyFile[] smartRoots = new JRubyFile[roots.length]; for(int i = 0, j = roots.length; i < j; i++) { smartRoots[i] = new JRubyFile(roots[i].getPath()); } return smartRoots; }
@Override public File getAbsoluteFile() { return new JRubyFile(getAbsolutePath()); }
@Override public File getAbsoluteFile() { return new JRubyFile(getAbsolutePath()); }
@Override public File getParentFile() { String par = getParent(); if (par == null) { return this; } else { return new JRubyFile(par); } }
public static File[] listRoots() { File[] roots = File.listRoots(); JRubyFile[] smartRoots = new JRubyFile[roots.length]; for(int i = 0, j = roots.length; i < j; i++) { smartRoots[i] = new JRubyFile(roots[i].getPath()); } return smartRoots; }
@Override public File getAbsoluteFile() { return new JRubyFile(getAbsolutePath()); }
@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 JRubyFile createNoUnicodeConversion(String cwd, String pathname) { if (pathname == null || pathname.equals("") || Ruby.isSecurityRestricted()) { return JRubyNonExistentFile.NOT_EXIST; } File internal = new JavaSecuredFile(pathname); if(!internal.isAbsolute()) { internal = new JavaSecuredFile(cwd, pathname); if(!internal.isAbsolute()) { throw new IllegalArgumentException("Neither current working directory ("+cwd+") nor pathname ("+pathname+") led to an absolute path"); } } return new JRubyFile(internal); }
private static JRubyFile createNoUnicodeConversion(String cwd, String pathname) { if (pathname == null || pathname.equals("") || Ruby.isSecurityRestricted()) { return JRubyNonExistentFile.NOT_EXIST; } File internal = new JavaSecuredFile(pathname); if(!internal.isAbsolute()) { internal = new JavaSecuredFile(cwd, pathname); if(!internal.isAbsolute()) { throw new IllegalArgumentException("Neither current working directory ("+cwd+") nor pathname ("+pathname+") led to an absolute path"); } } return new JRubyFile(internal); }