예제 #1
0
        public RubyBufferedStream /*!*/ GetWritableStream()
        {
            var result = GetStream();

            if (!_mode.CanWrite())
            {
                throw RubyExceptions.CreateIOError("not opened for writing");
            }
            if (!result.CanWrite)
            {
                throw RubyExceptions.CreateEBADF();
            }
            return(result);
        }
예제 #2
0
파일: IoOps.cs 프로젝트: ltwlf/IronSP
        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 /*!*/ GetWritableContent()
 {
     if (!_mode.CanWrite())
     {
         throw RubyExceptions.CreateIOError("not opened for writing");
     }
     return(_content);
 }
예제 #4
0
        private static MutableString/*!*/ CheckContent(MutableString/*!*/ content, IOMode mode) {
            if (content.IsFrozen && mode.CanWrite()) {
                throw Errno.CreateEACCES("Permission denied");
            }

            if ((mode & IOMode.Truncate) != 0) {
                content.Clear();
            }
            return content;
        }
예제 #5
0
        private static MutableString /*!*/ CheckContent(MutableString /*!*/ content, IOMode mode)
        {
            if (content.IsFrozen && mode.CanWrite())
            {
                throw Errno.CreateEACCES("Permission denied");
            }

            if ((mode & IOMode.Truncate) != 0)
            {
                content.Clear();
            }
            return(content);
        }
예제 #6
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);
        }
예제 #7
0
 public static IOMode CloseRead(this IOMode mode)
 {
     return((mode & ~IOMode.ReadWriteMask) | (mode.CanWrite() ? IOMode.WriteOnly : IOMode.Closed));
 }