@Override public boolean exists() { // MRI behavior: Even broken symlinks should return true. return file.exists() || isSymLink(); }
@Override public boolean exists() { if (file.exists()) { String path = filePath; if (path.length() > 1 && path.charAt(path.length() - 1) == '/') { path = file.getPathDefault(); if (path.length() > 0 && path.charAt(path.length() - 1) != '/' && !isDirectory()) { return false; } } return true; } return false; }
@Override public boolean exists() { if (file.exists()) { String path = filePath; if (path.length() > 1 && path.charAt(path.length() - 1) == '/') { path = file.getPathDefault(); if (path.length() > 0 && path.charAt(path.length() - 1) != '/' && !isDirectory()) { return false; } } return true; } return false; }
private void update() { if (snapshot == null || dir.exists() && dir.lastModified() > lastModified) { lastModified = dir.lastModified(); List<String> snapshotList = new ArrayList<String>(); snapshotList.add("."); snapshotList.add(".."); snapshotList.addAll(getContents(dir)); snapshot = (String[]) snapshotList.toArray(new String[snapshotList.size()]); } }
private void update() { if (snapshot == null || dir.exists() && dir.lastModified() > lastModified) { lastModified = dir.lastModified(); List<String> snapshotList = new ArrayList<String>(); snapshotList.add("."); snapshotList.add(".."); snapshotList.addAll(getContents(dir)); snapshot = (String[]) snapshotList.toArray(new String[snapshotList.size()]); } }
public static IRubyObject rowned_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isROwned()); }
@JRubyMethod(name = "file?", required = 1, module = true) public static RubyBoolean file_p(ThreadContext context, IRubyObject recv, IRubyObject filename) { Ruby runtime = context.runtime; if (!(filename instanceof RubyFile)) { filename = get_path(context, filename); } ZipEntry entry = file_in_archive(filename); if (entry != null) { return entry.isDirectory() ? recv.getRuntime().getFalse() : recv.getRuntime().getTrue(); } JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && file.isFile()); }
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; }
@JRubyMethod(name = "executable_real?", required = 1, module = true) public static IRubyObject executable_real_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutableReal()); }
@JRubyMethod(name = "chardev?", required = 1, module = true) public static IRubyObject chardev_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isCharDev()); }
@JRubyMethod(name = "owned?", required = 1, module = true) public static IRubyObject owned_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isOwned()); }
@JRubyMethod(name = "setuid?", required = 1, module = true) public static IRubyObject setuid_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetuid()); }
@JRubyMethod(name = "executable?", required = 1, module = true) public static IRubyObject executable_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutable()); }
@JRubyMethod(name = "sticky?", required = 1, module = true) public static IRubyObject sticky_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSticky()); }
@JRubyMethod(name = "blockdev?", required = 1, module = true) public static IRubyObject blockdev_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isBlockDev()); }
@JRubyMethod(name = "pipe?", required = 1, module = true) public static IRubyObject pipe_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isNamedPipe()); }
@JRubyMethod(name = "setgid?", required = 1, module = true) public static IRubyObject setgid_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetgid()); }
@JRubyMethod(name = "socket?", required = 1, module = true) public static IRubyObject socket_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSocket()); }
@JRubyMethod(name = "grpowned?", required = 1, module = true) public static IRubyObject grpowned_p(IRubyObject recv, IRubyObject filename) { Ruby runtime = recv.getRuntime(); JRubyFile file = file(filename); // JRUBY-4446, grpowned? always returns false on Windows if (Platform.IS_WINDOWS) { return runtime.getFalse(); } return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isGroupOwned()); }
public static IRubyObject directory_p(ThreadContext context, IRubyObject filename) { Ruby runtime = context.runtime; if (!(filename instanceof RubyFile || filename instanceof RubyIO)) { if (filename.respondsTo("to_io")) { filename = (RubyIO) TypeConverter.convertToType(filename, context.runtime.getIO(), "to_io"); } else { filename = get_path(context, filename); } } ZipEntry entry = file_in_archive(filename); if (entry != null) { return entry.isDirectory() ? runtime.getTrue() : runtime.getFalse(); } JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isDirectory()); }