Пример #1
0
        public RubyBufferedStream /*!*/ GetReadableStream()
        {
            var result = GetStream();

            if (!_mode.CanRead())
            {
                throw RubyExceptions.CreateIOError("not opened for reading");
            }
            if (!result.CanRead)
            {
                throw RubyExceptions.CreateEBADF();
            }
            return(result);
        }
Пример #2
0
        public static RubyIO /*!*/ OpenPipe(
            RubyContext /*!*/ context,
            MutableString /*!*/ command,
            IOMode mode)
        {
            bool redirectStandardInput  = mode.CanWrite();
            bool redirectStandardOutput = mode.CanRead();

            Process process = RubyProcess.CreateProcess(context, command, redirectStandardInput, redirectStandardOutput, false);

            StreamReader reader = null;
            StreamWriter writer = null;

            if (redirectStandardOutput)
            {
                reader = process.StandardOutput;
            }

            if (redirectStandardInput)
            {
                writer = process.StandardInput;
            }

            return(new RubyIO(context, reader, writer, mode));
        }
Пример #3
0
 private MutableString /*!*/ GetReadableContent()
 {
     if (!_mode.CanRead())
     {
         throw RubyExceptions.CreateIOError("not opened for reading");
     }
     return(_content);
 }
Пример #4
0
        public static RubyIO/*!*/ OpenPipe(
            RubyContext/*!*/ context, 
            MutableString/*!*/ command, 
            IOMode mode) {

            bool redirectStandardInput = mode.CanWrite();
            bool redirectStandardOutput = mode.CanRead();

            Process process = RubyProcess.CreateProcess(context, command, redirectStandardInput, redirectStandardOutput, false);

            StreamReader reader = null;
            StreamWriter writer = null;
            if (redirectStandardOutput) {
                reader = process.StandardOutput;
            }

            if (redirectStandardInput) {
                writer = process.StandardInput;
            }

            return new RubyIO(context, reader, writer, mode);
        }
Пример #5
0
 public static IOMode CloseWrite(this IOMode mode)
 {
     return((mode & ~IOMode.ReadWriteMask) | (mode.CanRead() ? IOMode.ReadOnly : IOMode.Closed));
 }