////////////////////////////////////////////////////////////////////////// // .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); }
public void print(OutStream @out) { lock (@out) { @out.printLine(toStr()); if (m_err != null) m_err.trace(@out, null, 2, true); } }
////////////////////////////////////////////////////////////////////////// // 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); }
public DotnetOutputStream(OutStream outs) { this.outs = outs; }
public virtual long pipe(OutStream output, Long n) { return pipe(output, n, true); }
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; }
public void err(OutStream err) { checkRun(); this.m_err = err; }
public static void make_(OutStream self, OutStream output) { self.m_out = output; }
public Err trace(OutStream @out) { return trace(@out, null, 0, true); }
public Err trace(OutStream @out) { return(trace(@out, null, 0, true)); }
/// <summary> /// Dump a readable stack trace. /// </summary> public static void dumpStack(Exception err, OutStream @out) { dumpStack(err.Message, err, @out, 0); }
////////////////////////////////////////////////////////////////////////// // GZIP ////////////////////////////////////////////////////////////////////////// public static OutStream gzipOutStream(OutStream o) { throw UnsupportedErr.make("Zip.gzipOutStream").val; }
////////////////////////////////////////////////////////////////////////// // Constructor ////////////////////////////////////////////////////////////////////////// public ObjEncoder(OutStream @out, Map options) { this.@out = @out; if (options != null) initOptions(options); }
private Zip(OutStream outs) { this.m_zipOut = new ZipOutputStream(SysOutStream.dotnet(outs)); }
public static Zip write(OutStream outs) { return new Zip(outs); }
public override void encode(char ch, OutStream output) { ((StrBufOutStream)output).m_sb.Append(ch); }
public static void make_(OutStream self, OutStream output) { self.m_out = output; if (output != null) self.charset(output.charset()); }
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(); } }
public Err trace(OutStream @out, Map opt) { return(trace(@out, opt, 0, true)); }
public abstract void encode(char ch, OutStream @out);
////////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////////// public static OutStream make(OutStream output) { OutStream self = new OutStream(); make_(self, output); return self; }
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]); }
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(); }
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); }
public Err trace(OutStream @out, Map opt) { return trace(@out, opt, 0, true); }
public override void encode(char c, OutStream @out) { @out.w((c >> 0) & 0xFF) .w((c >> 8) & 0xFF); }
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)); } }
public void @out(OutStream @out) { checkRun(); this.m_out = @out; }
public virtual long pipe(OutStream output) { return pipe(output, null, true); }