コード例 #1
0
ファイル: RubyIO.cs プロジェクト: zgramana/IronLanguages.PCG
        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
ファイル: StringIO.cs プロジェクト: parhelia512/ironruby
 private MutableString /*!*/ GetWritableContent()
 {
     if (!_mode.CanWrite())
     {
         throw RubyExceptions.CreateIOError("not opened for writing");
     }
     return(_content);
 }
コード例 #4
0
ファイル: StringIO.cs プロジェクト: jxnmaomao/ironruby
        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
ファイル: StringIO.cs プロジェクト: parhelia512/ironruby
        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
ファイル: IoOps.cs プロジェクト: ghouston/ironlanguages
        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));
 }