public static String ioOflagsModestr(Ruby runtime, int oflags) { int accmode = oflags & (OpenFlags.O_RDONLY.intValue()|OpenFlags.O_WRONLY.intValue()|OpenFlags.O_RDWR.intValue()); if ((oflags & OpenFlags.O_APPEND.intValue()) != 0) { if (accmode == OpenFlags.O_WRONLY.intValue()) { return MODE_BINARY(oflags, "a", "ab"); } if (accmode == OpenFlags.O_RDWR.intValue()) { return MODE_BINARY(oflags, "a+", "ab+"); } } switch (OpenFlags.valueOf(oflags & (OpenFlags.O_RDONLY.intValue()|OpenFlags.O_WRONLY.intValue()|OpenFlags.O_RDWR.intValue()))) { default: throw runtime.newArgumentError("invalid access oflags 0x" + Integer.toHexString(oflags)); case O_RDONLY: return MODE_BINARY(oflags, "r", "rb"); case O_WRONLY: return MODE_BINARY(oflags, "w", "wb"); case O_RDWR: return MODE_BINARY(oflags, "r+", "rb+"); } }
public static String ioOflagsModestr(Ruby runtime, int oflags) { int accmode = oflags & (OpenFlags.O_RDONLY.intValue()|OpenFlags.O_WRONLY.intValue()|OpenFlags.O_RDWR.intValue()); if ((oflags & OpenFlags.O_APPEND.intValue()) != 0) { if (accmode == OpenFlags.O_WRONLY.intValue()) { return MODE_BINARY(oflags, "a", "ab"); } if (accmode == OpenFlags.O_RDWR.intValue()) { return MODE_BINARY(oflags, "a+", "ab+"); } } switch (OpenFlags.valueOf(oflags & (OpenFlags.O_RDONLY.intValue()|OpenFlags.O_WRONLY.intValue()|OpenFlags.O_RDWR.intValue()))) { default: throw runtime.newArgumentError("invalid access oflags 0x" + Integer.toHexString(oflags)); case O_RDONLY: return MODE_BINARY(oflags, "r", "rb"); case O_WRONLY: return MODE_BINARY(oflags, "w", "wb"); case O_RDWR: return MODE_BINARY(oflags, "r+", "rb+"); } }