Exemplo n.º 1
0
        public void Init(string name)
        {
            Debug.Assert(m_handle.IsNull());
            Debug.Assert(FileVar == 0);

            var streams = new FileStreams();

            streams.BaseStream = new MemoryStream();
            m_handle.AttachResource(streams);

            _Invalidate();
        }
Exemplo n.º 2
0
        public void Init(Int32 index)
        {
            Debug.Assert(m_handle.IsNull());
            Debug.Assert(FileVar == 0);

            var filename = Runtime.GetFileName(index);

            var streams = new FileStreams();

            m_handle.AttachResource(streams);

            if (index == Runtime.INPUT_FILE_IDX)
            {
                if (filename == null)
                {
                    streams.Reader = Console.In;
                }
                else
                {
                    // BaseStream is not set for input/output
                    //
                    streams.Reader = new StreamReader(new FileStream(filename, FileMode.Open));
                }
            }
            else if (index == Runtime.OUTPUT_FILE_IDX)
            {
                if (filename == null)
                {
                    streams.Writer = Console.Out;
                }
                else
                {
                    // BaseStream is not set for input/output
                    //
                    streams.Writer = new StreamWriter(new FileStream(filename, FileMode.Create));
                }
            }
            else
            {
                streams.BaseStream = new FileStream(filename, FileMode.OpenOrCreate);
            }

            _Invalidate();
        }