示例#1
0
        public static object OpenTcpInputOutputPort(object host, object port, object maybetranscoder)
        {
            TcpClient tcp = new TcpClient();

            tcp.Connect(RequiresNotNull <string>(host), RequiresNotNull <int>(port));

            NetworkStream ns = tcp.GetStream();

            if (maybetranscoder is R6RS.Transcoder)
            {
                R6RS.Transcoder tc = maybetranscoder as R6RS.Transcoder;
                return(new R6RS.CustomTextReaderWriter(
                           SymbolTable.StringToObject(string.Format("#<tcp-textual-input/output-port {0}:{1}>", host, port)),
                           new StreamReader(ns, tc.codec), new StreamWriter(ns, tc.codec)));
            }
            else
            {
                return(ns);
            }
        }
示例#2
0
        public static object OpenFileInputOutputPort(object filename, object fileoptions, object buffermode, object maybetranscoder)
        {
            string      fn          = RequiresNotNull <string>(filename);
            FileOptions fo          = ToFileOptions(fileoptions);
            FileMode    fm          = GetMode(fo, fn);
            Transcoder  tc          = maybetranscoder as Transcoder;
            bool        blockbuffer = buffermode == SymbolTable.StringToObject("block");

            try
            {
                Stream s = File.Open(fn, fm, FileAccess.ReadWrite);

                if (blockbuffer)
                {
                    s = new BufferedStream(s);
                }

                if (tc == null)
                {
                    return(s);
                }
                else
                {
                    return(TranscodedInputOutputPort(s, tc));
                }
            }
            catch (Continuation)
            {
                throw;
            }
            catch (FileNotFoundException ex)
            {
                return(FileNotFoundViolation("open-file-input/output-port", ex.Message, filename));
            }
            catch (Exception ex)
            {
                return(AssertionViolation("open-file-input/output-port", ex.Message, filename));
            }
        }
示例#3
0
 public TranscodedReader(Stream s, Transcoder tc)
 {
     this.tc   = tc;
     this.port = s;
 }
示例#4
0
 public TranscodedWriter(Stream s, Transcoder tc)
 {
     NewLine   = "\n";
     this.tc   = tc;
     this.port = s;
 }
示例#5
0
 static Transcoder()
 {
     native = new Transcoder();
 }
示例#6
0
 public NonBufferedTranscodedReader(Stream s, Transcoder tc)
 {
     this.tc   = tc;
     this.port = s;
 }
示例#7
0
 public TranscodedReader(Stream s, Transcoder tc) : base(s, tc.codec, true)
 {
     this.tc   = tc;
     this.port = s;
 }
示例#8
0
文件: IO.cs 项目: robertlj/IronScheme
 static Transcoder()
 {
     native = new Transcoder();
 }
示例#9
0
文件: IO.cs 项目: robertlj/IronScheme
 public TranscodedWriter(Stream s, Transcoder tc)
 {
     NewLine = "\n";
       this.tc = tc;
       this.port = s;
 }
示例#10
0
文件: IO.cs 项目: robertlj/IronScheme
 public TranscodedReader(Stream s, Transcoder tc)
 {
     this.tc = tc;
       this.port = s;
 }