OutStream.
Inheritance: FanObj
Exemple #1
0
 //////////////////////////////////////////////////////////////////////////
 // .NET Conversion
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Get a System.IO.Stream for the specified output stream.
 /// </summary>
 public static Stream dotnet(OutStream outs)
 {
     if (outs is SysOutStream)
     return ((SysOutStream)outs).outStream;
       else
     return new DotnetOutputStream(outs);
 }
Exemple #2
0
 public void print(OutStream @out)
 {
     lock (@out)
       {
     @out.printLine(toStr());
     if (m_err != null) m_err.trace(@out, null, 2, true);
       }
 }
Exemple #3
0
 //////////////////////////////////////////////////////////////////////////
 // Construction
 //////////////////////////////////////////////////////////////////////////
 public BootEnv()
 {
     this.m_args    = initArgs();
       this.m_vars    = initVars();
       this.m_host    = initHost();
       this.m_user    = initUser();
       this.m_in      = new SysInStream(Console.OpenStandardInput());
       this.m_out     = new SysOutStream(Console.OpenStandardOutput());
       this.m_err     = new SysOutStream(Console.OpenStandardError());
       this.m_homeDir = new LocalFile(new DirectoryInfo(Sys.m_homeDir), true).normalize();
       this.m_tempDir = m_homeDir.plus(Uri.fromStr("temp/"), false);
 }
Exemple #4
0
 public virtual long pipe(OutStream output, Long n)
 {
     return pipe(output, n, true);
 }
Exemple #5
0
 public void err(OutStream err)
 {
     checkRun(); this.m_err = err;
 }
Exemple #6
0
 public Err trace(OutStream @out, Map opt, int indent, bool useActual)
 {
     Exception ex = m_actual != null && useActual ? m_actual : val;
       dumpStack(toStr(), ex, @out, indent);
       if (m_cause != null)
       {
     @out.printLine("Cause:");
     m_cause.trace(@out, opt, indent+2, useActual);
       }
       return this;
 }
Exemple #7
0
 public Err trace(OutStream @out)
 {
     return trace(@out, null, 0, true);
 }
Exemple #8
0
 public static void make_(OutStream self, OutStream output)
 {
     self.m_out = output;
 }
Exemple #9
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 public ObjEncoder(OutStream @out, Map options)
 {
     [email protected] = @out;
       if (options != null) initOptions(options);
 }
Exemple #10
0
 //////////////////////////////////////////////////////////////////////////
 // GZIP
 //////////////////////////////////////////////////////////////////////////
 public static OutStream gzipOutStream(OutStream o)
 {
     throw UnsupportedErr.make("Zip.gzipOutStream").val;
 }
Exemple #11
0
 private Zip(OutStream outs)
 {
     this.m_zipOut = new ZipOutputStream(SysOutStream.dotnet(outs));
 }
Exemple #12
0
 public static Zip write(OutStream outs)
 {
     return new Zip(outs);
 }
Exemple #13
0
 public static void make_(OutStream self, OutStream output)
 {
     self.m_out = output;
       if (output != null) self.charset(output.charset());
 }
Exemple #14
0
 public virtual long pipe(OutStream output, Long toPipe, bool cls)
 {
     try
       {
     long bufSize = FanInt.Chunk.longValue();
     Buf buf = Buf.make(bufSize);
     long total = 0;
     if (toPipe == null)
     {
       while (true)
       {
     Long n = readBuf(buf.clear(), bufSize);
     if (n == null) break;
     output.writeBuf(buf.flip(), buf.remaining());
     total += n.longValue();
       }
     }
     else
     {
       long toPipeVal = toPipe.longValue();
       while (total < toPipeVal)
       {
     if (toPipeVal - total < bufSize) bufSize = toPipeVal - total;
     Long n = readBuf(buf.clear(), bufSize);
     if (n == null) throw IOErr.make("Unexpected end of stream").val;
     output.writeBuf(buf.flip(), buf.remaining());
     total += n.longValue();
       }
     }
     return total;
       }
       finally
       {
     if (cls) close();
       }
 }
Exemple #15
0
 public abstract void encode(char ch, OutStream @out);
Exemple #16
0
 //////////////////////////////////////////////////////////////////////////
 // Construction
 //////////////////////////////////////////////////////////////////////////
 public static OutStream make(OutStream output)
 {
     OutStream self = new OutStream();
       make_(self, output);
       return self;
 }
Exemple #17
0
 public override void encode(char ch, OutStream @out)
 {
     cbuf[0] = ch;
     int len = charset.m_encoding.GetBytes(cbuf, 0, 1, bbuf, 0);
     for (int i=0; i<len; i++)
       @out.w(bbuf[i]);
 }
Exemple #18
0
 public static void dumpStack(string msg, Exception err, OutStream @out, int indent)
 {
     StringWriter w = new StringWriter();
       doDumpStack(msg, err, indent, w);
       @out.writeChars(w.ToString()).flush();
 }
Exemple #19
0
 public override void encode(char c, OutStream @out)
 {
     if (c > 0xFF) throw IOErr.make("Invalid ISO-8859-1 char").val;
     @out.w((c >> 0) & 0xFF);
 }
Exemple #20
0
 public Err trace(OutStream @out, Map opt)
 {
     return trace(@out, opt, 0, true);
 }
Exemple #21
0
 public override void encode(char c, OutStream @out)
 {
     @out.w((c >> 0) & 0xFF)
     .w((c >> 8) & 0xFF);
 }
Exemple #22
0
 /// <summary>
 /// Dump a readable stack trace.
 /// </summary>
 public static void dumpStack(Exception err, OutStream @out)
 {
     dumpStack(err.Message, err, @out, 0);
 }
Exemple #23
0
 public override void encode(char c, OutStream @out)
 {
     if (c <= 0x007F)
     {
       @out.w(c);
     }
     else if (c > 0x07FF)
     {
       @out.w(0xE0 | ((c >> 12) & 0x0F))
       .w(0x80 | ((c >>  6) & 0x3F))
       .w(0x80 | ((c >>  0) & 0x3F));
     }
     else
     {
       @out.w(0xC0 | ((c >>  6) & 0x1F))
       .w(0x80 | ((c >>  0) & 0x3F));
     }
 }
Exemple #24
0
 public void @out(OutStream @out)
 {
     checkRun(); this.m_out = @out;
 }
Exemple #25
0
 public DotnetOutputStream(OutStream outs)
 {
     this.outs = outs;
 }
Exemple #26
0
 public override void encode(char ch, OutStream output)
 {
     ((StrBufOutStream)output).m_sb.Append(ch);
 }
Exemple #27
0
 public virtual long pipe(OutStream output)
 {
     return pipe(output, null, true);
 }