////////////////////////////////////////////////////////////////////////// // Constructor ////////////////////////////////////////////////////////////////////////// public static SysInStream make(Stream input, Long bufSize) { if (bufSize == null || bufSize.longValue() == 0) return new SysInStream(input); else return new SysInStream(new BufferedStream(input, bufSize.intValue())); }
public override InStream @in(Long bufSize) { try { System.IO.Stream ins; if (m_parent is Zip) { // never buffer if using ZipInputStream ins = new ZipEntryInputStream((m_parent as Zip).m_zipIn); } else { ins = (m_parent as ZipFile).GetInputStream(m_entry); // buffer if specified if (bufSize != null && bufSize.longValue() != 0) ins = new System.IO.BufferedStream(ins, bufSize.intValue()); } // return as fan stream return new SysInStream(ins); } catch (System.IO.IOException e) { throw IOErr.make(e).val; } }
public static Stream toBuffered(Stream output, Long bufSize) { if (bufSize == null || bufSize.longValue() == 0) return output; else return new BufferedStream(output, bufSize.intValue()); }
public override InStream @in(Long bufSize) { try { System.IO.Stream ins; if (m_parent is Zip) { // never buffer if using ZipInputStream ins = new ZipEntryInputStream((m_parent as Zip).m_zipIn); } else { ins = (m_parent as ZipFile).GetInputStream(m_entry); // buffer if specified if (bufSize != null && bufSize.longValue() != 0) { ins = new System.IO.BufferedStream(ins, bufSize.intValue()); } } // return as fan stream return(new SysInStream(ins)); } catch (System.IO.IOException e) { throw IOErr.make(e).val; } }
public virtual Long peekChar() { Long x = readChar(); if (x != null) { unreadChar(x.longValue()); } return(x); }
////////////////////////////////////////////////////////////////////////// // Constructor ////////////////////////////////////////////////////////////////////////// public static SysInStream make(Stream input, Long bufSize) { if (bufSize == null || bufSize.longValue() == 0) { return(new SysInStream(input)); } else { return(new SysInStream(new BufferedStream(input, bufSize.intValue()))); } }
public static Stream toBuffered(Stream output, Long bufSize) { if (bufSize == null || bufSize.longValue() == 0) { return(output); } else { return(new BufferedStream(output, bufSize.intValue())); } }
public object removeSame(object val) { // modify in removeAt(long) Long i = indexSame(val); if (i == null) { return(null); } return(removeAt(i.longValue())); }
public virtual Buf readBufFully(Buf buf, long n) { if (buf == null) { buf = Buf.make(n); } long total = n; long got = 0; while (got < total) { Long r = readBuf(buf, total - got); if (r == null || r.longValue() == 0) { throw IOErr.make("Unexpected end of stream").val; } got += r.longValue(); } buf.flip(); return(buf); }
public List moveTo(object item, long toIndex) { modify(); Long curIndex = index(item); if (curIndex == null) { return(this); } if (curIndex.longValue() == toIndex) { return(this); } removeAt(curIndex.longValue()); if (toIndex == -1) { return(add(item)); } if (toIndex < 0) { ++toIndex; } return(insert(toIndex, item)); }
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 virtual string readLine(Long max) { // max limit int maxChars = System.Int32.MaxValue; if (max != null) { long maxLong = max.longValue(); if (maxLong == 0L) { return(""); } if (maxLong < 0) { throw ArgErr.make("Invalid max: " + max).val; } if (maxLong < System.Int32.MaxValue) { maxChars = (int)maxLong; } } // read first char, if at end of file bail int c = rChar(); if (c < 0) { return(null); } // loop reading chars until we hit newline // combo or end of stream StringBuilder buf = new StringBuilder(256); while (true) { // check for \n, \r\n, or \r if (c == '\n') { break; } if (c == '\r') { c = rChar(); if (c >= 0 && c != '\n') { unreadChar(c); } break; } // Append to working buffer buf.Append((char)c); if (buf.Length >= maxChars) { break; } // read next char c = rChar(); if (c < 0) { break; } } return(buf.ToString()); }
public virtual string readLine(Long max) { // max limit int maxChars = System.Int32.MaxValue; if (max != null) { long maxLong = max.longValue(); if (maxLong == 0L) return ""; if (maxLong < 0) throw ArgErr.make("Invalid max: " + max).val; if (maxLong < System.Int32.MaxValue) maxChars = (int)maxLong; } // read first char, if at end of file bail int c = rChar(); if (c < 0) return null; // loop reading chars until we hit newline // combo or end of stream StringBuilder buf = new StringBuilder(256); while (true) { // check for \n, \r\n, or \r if (c == '\n') break; if (c == '\r') { c = rChar(); if (c >= 0 && c != '\n') unreadChar(c); break; } // Append to working buffer buf.Append((char)c); if (buf.Length >= maxChars) break; // read next char c = rChar(); if (c < 0) break; } return buf.ToString(); }
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(); } }