Examples of FileStat


Examples of jnr.posix.FileStat

        Ruby runtime = context.runtime;
        if (!(filename instanceof RubyFile)) {
            filename = get_path(context, filename);
        }

        FileStat stat = fileResource(filename).stat();
        return runtime.newBoolean(stat != null && stat.isReadable());
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return runtime.newBoolean(stat != null && stat.isReadable());
    }

    // Not exposed by filetest, but so similiar in nature that it is stored here
    public static IRubyObject rowned_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isROwned());
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return recv.getRuntime().newBoolean(stat != null && stat.isROwned());
    }

    @JRubyMethod(name = "setgid?", required = 1, module = true)
    public static IRubyObject setgid_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isSetgid());
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return recv.getRuntime().newBoolean(stat != null && stat.isSetgid());
    }

    @JRubyMethod(name = "setuid?", required = 1, module = true)
    public static IRubyObject setuid_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isSetuid());
    }
View Full Code Here

Examples of jnr.posix.FileStat

    public static IRubyObject size(ThreadContext context, IRubyObject recv, IRubyObject filename) {
        if (!(filename instanceof RubyFile) && filename.respondsTo("to_io")) {
             filename = TypeConverter.convertToType(filename, context.runtime.getIO(), "to_io");
        }

        FileStat stat = fileResource(filename).stat();

        if (stat == null) noFileError(filename);

        return context.runtime.newFixnum(stat.st_size());
    }
View Full Code Here

Examples of jnr.posix.FileStat

        Ruby runtime = context.runtime;
        if (!(filename instanceof RubyFile) && filename.respondsTo("to_io")) {
            filename = TypeConverter.convertToType(filename, runtime.getIO(), "to_io");
        }

        FileStat stat = fileResource(filename).stat();

        if (stat == null) return runtime.getNil();

        long length = stat.st_size();
        return length > 0 ? runtime.newFixnum(length) : runtime.getNil();
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return length > 0 ? runtime.newFixnum(length) : runtime.getNil();
    }

    @JRubyMethod(name = "socket?", required = 1, module = true)
    public static IRubyObject socket_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isSocket());
    }
View Full Code Here

Examples of jnr.posix.FileStat

        return recv.getRuntime().newBoolean(stat != null && stat.isSocket());
    }

    @JRubyMethod(name = "sticky?", required = 1, module = true)
    public static IRubyObject sticky_p(IRubyObject recv, IRubyObject filename) {
        FileStat stat = fileResource(filename).stat();

        return recv.getRuntime().newBoolean(stat != null && stat.isSticky());
    }
View Full Code Here

Examples of jnr.posix.FileStat

            // Note: We can't use file.exists() to check whether the symlink
            // exists or not, because that method returns false for existing
            // but broken symlink. So, we try without the existence check,
            // but in the try-catch block.
            // MRI behavior: symlink? on broken symlink should return true.
            FileStat stat = fileResource(filename).lstat();

            return runtime.newBoolean(stat != null && stat.isSymlink());
        } catch (SecurityException re) {
            return runtime.getFalse();
        } catch (RaiseException re) {
            runtime.getGlobalVariables().set("$!", oldExc);
            return runtime.getFalse();
View Full Code Here

Examples of jnr.posix.FileStat

    @JRubyMethod(name = "zero?", required = 1, module = true)
    public static RubyBoolean zero_p(ThreadContext context, IRubyObject recv, IRubyObject filename) {
        Ruby runtime = context.runtime;

        FileStat stat = fileResource(context, filename).stat();

        if (stat == null) return runtime.getFalse();
        // MRI behavior, enforced by RubySpecs.
        if (stat.isDirectory()) return runtime.newBoolean(Platform.IS_WINDOWS);

        return runtime.newBoolean(stat.st_size() == 0L);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.