Package org.jruby.util.io

Examples of org.jruby.util.io.ModeFlags


        }
    }

    public static IOOptions newIOOptions(Ruby runtime, IOOptions oldFlags, int orOflags) {
        try {
            return new IOOptions(new ModeFlags(oldFlags.getModeFlags().getFlags() | orOflags), oldFlags.getEncodingOption());
        } catch (InvalidValueException ive) {
            throw runtime.newErrnoEINVALError();
        }
    }
View Full Code Here


    }

    private InputStream wrapJRubyNormalizedInputStream(String file) throws IOException {
        Ruby runtime = Ruby.getGlobalRuntime();
        try {
            ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), file, new ModeFlags(ModeFlags.RDONLY));
            return ChannelStream.open(runtime, descriptor).newInputStream();
        } catch (NoSuchMethodError nsme) {
            return new BufferedInputStream(new FileInputStream(file));
        } catch (FileExistsException fee) {
            // should not happen because ModeFlag does not contain CREAT.
View Full Code Here

        }
    }

    protected static ChannelDescriptor newChannelDescriptor(Ruby runtime, Channel channel) {
        ModeFlags modeFlags = newModeFlags(runtime, ModeFlags.RDWR);

        return new ChannelDescriptor(channel, modeFlags);
    }
View Full Code Here

        }
    }

    protected void init_sock(Ruby runtime) {
        try {
            ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR);

            openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(channel, modes)));
            openFile.setPipeStream(openFile.getMainStreamSafe());
            openFile.setMode(modes.getOpenFileFlags());
            openFile.getMainStreamSafe().setSync(true);

        } catch (BadDescriptorException e) {
            throw runtime.newErrnoEBADFError();
        }
View Full Code Here

            } else {
                throw runtime.newArgumentError("unsupported server socket type `" + soType + "'");

            }

            ModeFlags modeFlags = newModeFlags(runtime, ModeFlags.RDWR);

            return new ChannelDescriptor(channel, modeFlags);

        } catch(IOException e) {
            throw SocketUtils.sockerr(runtime, "initialize: " + e.toString());
View Full Code Here

    }

    protected void init_sock(Ruby runtime, Channel channel, String path) {
        MakeOpenFile();
       
        ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR);

        openFile.setFD(newChannelFD(runtime, channel));
        openFile.setMode(modes.getOpenFileFlags());
        openFile.setSync(true);
        openFile.setPath(path);
    }
View Full Code Here

        io.MakeOpenFile();
       
        Object pm = vmodeVperm(pmode, runtime.newFixnum(0));
        int[] oflags_p = {0}, fmode_p = {0};
        EncodingUtils.extractModeEncoding(context, io, pm, options, oflags_p, fmode_p);
        ModeFlags modes = ModeFlags.createModeFlags(oflags_p[0]);
       
        // FIXME: Reprocessing logic twice for now...
        // for 1.9 mode, strip off the trailing options hash, if there
        if (args.length > 1 && args[args.length - 1] instanceof RubyHash) {
            options = (RubyHash)args[args.length - 1];
View Full Code Here

        return newModeFlags(runtime, (int) mode);
    }

    public static ModeFlags newModeFlags(Ruby runtime, int mode) {
        try {
            return new ModeFlags(mode);
        } catch (InvalidValueException ive) {
            throw runtime.newErrnoEINVALError();
        }
    }
View Full Code Here

        }
    }

    public static ModeFlags newModeFlags(Ruby runtime, String mode) {
        try {
            return new ModeFlags(mode);
        } catch (InvalidValueException ive) {
            // This is used by File and StringIO, which seem to want an ArgumentError instead of EINVAL
            throw runtime.newArgumentError("illegal access mode " + mode);      
        }
    }
View Full Code Here

        return newIOOptions(runtime, (int) mode);
    }

    public static IOOptions newIOOptions(Ruby runtime, int mode) {
        try {
            ModeFlags modeFlags = new ModeFlags(mode);
            return new IOOptions(modeFlags);
        } catch (InvalidValueException ive) {
            throw runtime.newErrnoEINVALError();
        }
    }
View Full Code Here

TOP

Related Classes of org.jruby.util.io.ModeFlags

Copyright © 2018 www.massapicom. 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.