Package org.jruby.util.io

Examples of org.jruby.util.io.OpenFile.checkReadable()


    @JRubyMethod(name = "getc", compat = RUBY1_9)
    public IRubyObject getc19(ThreadContext context) {
        try {
            OpenFile myOpenFile = getOpenFileChecked();

            myOpenFile.checkReadable(context.runtime);
            myOpenFile.setReadBuffered();

            Stream stream = myOpenFile.getMainStreamSafe();
           
            readCheck(stream);
View Full Code Here


    public int getcCommon() {
        try {
            OpenFile myOpenFile = getOpenFileChecked();

            myOpenFile.checkReadable(getRuntime());
            myOpenFile.setReadBuffered();

            Stream stream = myOpenFile.getMainStreamSafe();
           
            readCheck(stream);
View Full Code Here

    }

    public void ungetcCommon(int ch) {
        try {
            OpenFile myOpenFile = getOpenFileChecked();
            myOpenFile.checkReadable(getRuntime());
            myOpenFile.setReadBuffered();

            if (myOpenFile.getMainStreamSafe().ungetc(ch) == -1 && ch != -1) {
                throw getRuntime().newIOError("ungetc failed");
            }
View Full Code Here

        string.empty();
        string.setTaint(true);
       
        try {
            OpenFile myOpenFile = getOpenFileChecked();
            myOpenFile.checkReadable(runtime);
           
            if (length == 0) {
                return string;
            }
View Full Code Here

                buffer.length(0);
            }
           
            OpenFile myOpenFile = getOpenFileChecked();
           
            myOpenFile.checkReadable(getRuntime());
           
            if (myOpenFile.getMainStreamSafe().readDataBuffered()) {
                throw getRuntime().newIOError("sysread for buffered IO");
            }
           
View Full Code Here

    public IRubyObject read(ThreadContext context) {
        Ruby runtime = context.runtime;
        OpenFile myOpenFile = getOpenFileChecked();
       
        try {
            myOpenFile.checkReadable(runtime);
            myOpenFile.setReadBuffered();
            return readAll();
        } catch (InvalidValueException ex) {
            throw getRuntime().newErrnoEINVALError();
        } catch (EOFException ex) {
View Full Code Here

    public IRubyObject read(ThreadContext context, IRubyObject arg0, IRubyObject arg1) {
        OpenFile myOpenFile = getOpenFileChecked();
       
        if (arg0.isNil()) {
            try {
                myOpenFile.checkReadable(getRuntime());
                myOpenFile.setReadBuffered();
                if (arg1.isNil()) {
                    return readAll();
                } else {
                    return readAll(arg1.convertToString());
View Full Code Here

       
      try {
            OpenFile myOpenFile = getOpenFileChecked();
           
            while (true) {
                myOpenFile.checkReadable(runtime);
                myOpenFile.setReadBuffered();
                waitReadable(myOpenFile.getMainStream());
               
                int c = myOpenFile.getMainStreamSafe().fgetc();
               
View Full Code Here

        Ruby runtime = context.runtime;
        try {
            OpenFile openFile = ((RubyIO) src).getOpenFile();
            openFile.checkClosed();
            openFile.checkReadable(context);


            ByteBuffer buffer = ((AbstractMemory) dst).getMemoryIO().asByteBuffer();
            int count = RubyNumeric.num2int(rbLength);
View Full Code Here

        int len;
//        ioctl_arg n;
        RubyIO io = (RubyIO)_io;

        fptr = io.getOpenFileChecked();
        fptr.checkReadable(context);
        len = fptr.readPending();
        if (len > 0) return runtime.newFixnum(len);
        // TODO: better effort to get available bytes from our channel
//        if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0);
//        if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0);
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.