Package org.jruby.util.io

Examples of org.jruby.util.io.IOOptions


    }

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


        }
    }

    public static IOOptions newIOOptions(Ruby runtime, String mode) {
        try {
            return new IOOptions(runtime, 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

        }
    }

    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

        RubyString filename = get_path(context, args[0]);

        path = adjustRootPathOnWindows(runtime, filename.asJavaString(), runtime.getCurrentDirectory());

        String modeString = "r";
        IOOptions modes = newIOOptions(runtime, modeString);
        RubyHash options = null;
        int perm = 0;

        if (args.length > 1) {
            if (args[1] instanceof RubyHash) {
View Full Code Here

        RubyString filename = get_path(runtime.getCurrentContext(), args[0]);

        path = adjustRootPathOnWindows(runtime, filename.asJavaString(), runtime.getCurrentDirectory());

        String modeString;
        IOOptions modes;
        int perm;

        if ((args.length > 1 && args[1] instanceof RubyFixnum) || (args.length > 2 && !args[2].isNil())) {
            modes = parseIOOptions(args[1]);
            perm = getFilePermissions(args);

            sysopenInternal(path, modes.getModeFlags(), perm);
        } else {
            modeString = "r";
            if (args.length > 1 && !args[1].isNil()) {
                modeString = args[1].convertToString().toString();
            }
View Full Code Here

        if (path.startsWith("jar:")) {
            path = path.substring(4);
        }
        openFile = new OpenFile();

        IOOptions modes = newIOOptions(getRuntime(), modeString);
        openFile.setMode(modes.getModeFlags().getOpenFileFlags());
        if (modes.getModeFlags().isBinary()) readEncoding = ASCIIEncoding.INSTANCE;
        openFile.setPath(path);
        openFile.setMainStream(fopen(path, modes.getModeFlags()));
    }
View Full Code Here

    }

    private void initializeOpen() {
        Ruby runtime = getRuntime();

        IOOptions ioOptions = newIOOptions(runtime, ModeFlags.RDWR | ModeFlags.EXCL);
        getRuntime().getPosix().chmod(path, 0600);
        sysopenInternal(path, ioOptions.getModeFlags(), 0600);
    }
View Full Code Here

        if (arg instanceof RubyFixnum) return newIOOptions(runtime, (int) RubyFixnum.fix2long(arg));

        String modeString = arg.convertToString().toString();
        try {
            return new IOOptions(runtime, modeString);
        } catch (InvalidValueException ive) {
            throw runtime.newArgumentError("invalid access mode " + modeString);
        }
    }
View Full Code Here

            throw runtime.newArgumentError("illegal access mode " + mode);      
        }
    }

    public static IOOptions newIOOptions(Ruby runtime, ModeFlags modeFlags) {
        return new IOOptions(modeFlags);
    }
View Full Code Here

    }

    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.IOOptions

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.