@Override public File getAbsoluteFile() { String absolute = getAbsolutePath(); if (absolute != null) { return new JavaSecuredFile(absolute); } else { return null; } }
@Override public File getCanonicalFile() throws IOException { String path = getCanonicalPath(); return path == null ? null : new JavaSecuredFile(path); }
@Override public File getParentFile() { String path = getParent(); return path == null ? null : new JavaSecuredFile(path); }
@Override public File[] listFiles() { File[] files = super.listFiles(); if (files == null) { return null; } JRubyFile[] smartFiles = new JRubyFile[files.length]; for (int i = 0, j = files.length; i < j; i++) { smartFiles[i] = createNoUnicodeConversion(super.getAbsolutePath(), files[i].getPath()); } return smartFiles; }
@Override public String getCanonicalPath() throws IOException { return super.getCanonicalPath().replace(File.separatorChar, '/'); }
@Override public String getParent() { return super.getParent().replace(File.separatorChar, '/'); }
public int rmdir(String path) { return new JavaSecuredFile(path).delete() ? 0 : -1; }
final String getPathDefault() { return super.getPath(); }
public int mkdir(String path, int mode) { File dir = new JavaSecuredFile(path); if (!dir.mkdir()) return -1; chmod(path, mode); return 0; }
@Override public File[] listFiles(FilenameFilter filter) { File[] files = super.listFiles(filter); if (files == null) { return null; } else { NormalizedFile[] smartFiles = new NormalizedFile[files.length]; for (int i = 0; i < files.length; i++) { smartFiles[i] = new NormalizedFile(files[i].getPath()); } return smartFiles; } }
@Override public String[] list() { return super.list(); }
private JRubyFile[] convertFiles(final File[] files) { if (files == null) return null; // non-existent directory final String absolutePath = super.getAbsolutePath(); JRubyFile[] smartFiles = new JRubyFile[files.length]; for (int i = 0; i < files.length; i++) { final File file = files[i]; smartFiles[i] = createNoUnicodeConversion(absolutePath, file.getPath(), file); } return smartFiles; }
@Override public String toString() { return super.toString().replace(File.separatorChar, '/'); }
@Override public File[] listFiles(final FileFilter filter) { final File[] files = super.listFiles(filter); if (files == null) { return null; } JRubyFile[] smartFiles = new JRubyFile[files.length]; for (int i = 0,j = files.length; i < j; i++) { smartFiles[i] = createNoUnicodeConversion(super.getAbsolutePath(), files[i].getPath()); } return smartFiles; }
@Override public String getCanonicalPath() throws IOException { return super.getCanonicalPath().replace(File.separatorChar, '/'); }
@Override public String getParent() { return super.getParent().replace(File.separatorChar, '/'); }
public int rmdir(String path) { return new JavaSecuredFile(path).delete() ? 0 : -1; }
final String getPathDefault() { return super.getPath(); }
public int mkdir(String path, int mode) { File dir = new JavaSecuredFile(path); if (!dir.mkdir()) return -1; chmod(path, mode); return 0; }
@Override public File[] listFiles(final FilenameFilter filter) { return convertFiles(super.listFiles(filter)); }