/// <exception cref="NGit.Errors.CorruptObjectException"></exception> /// <exception cref="System.IO.IOException"></exception> internal PackIndexV1(InputStream fd, byte[] hdr) { byte[] fanoutTable = new byte[IDX_HDR_LEN]; System.Array.Copy(hdr, 0, fanoutTable, 0, hdr.Length); IOUtil.ReadFully(fd, fanoutTable, hdr.Length, IDX_HDR_LEN - hdr.Length); idxHeader = new long[256]; // really unsigned 32-bit... for (int k = 0; k < idxHeader.Length; k++) { idxHeader[k] = NB.DecodeUInt32(fanoutTable, k * 4); } idxdata = new byte[idxHeader.Length][]; for (int k_1 = 0; k_1 < idxHeader.Length; k_1++) { int n; if (k_1 == 0) { n = (int)(idxHeader[k_1]); } else { n = (int)(idxHeader[k_1] - idxHeader[k_1 - 1]); } if (n > 0) { idxdata[k_1] = new byte[n * (Constants.OBJECT_ID_LENGTH + 4)]; IOUtil.ReadFully(fd, idxdata[k_1], 0, idxdata[k_1].Length); } } objectCnt = idxHeader[255]; packChecksum = new byte[20]; IOUtil.ReadFully(fd, packChecksum, 0, packChecksum.Length); }
internal Attachment(InputStream contentStream, string contentType) { this.body = contentStream; metadata = new Dictionary<string, object>(); metadata.Put("content_type", contentType); metadata.Put("follows", true); this.gzipped = false; }
public StreamReader(InputStream stream) { if (stream == null) { throw new ArgumentNullException(); } _stream = stream; }
public MergedStream(com.fasterxml.jackson.core.io.IOContext ctxt, Sharpen.InputStream @in, byte[] buf, int start, int end) { _ctxt = ctxt; _in = @in; _b = buf; _ptr = start; _end = end; }
public ZInputStream(InputStream @in, int level) : base(@in) { this.@in = @in; z.DeflateInit(level); compress = true; z.next_in = buf; z.next_in_index = 0; z.avail_in = 0; }
public ZInputStream(InputStream @in, bool nowrap) : base(@in) { this.@in = @in; z.InflateInit(nowrap); compress = false; z.next_in = buf; z.next_in_index = 0; z.avail_in = 0; }
public static Com.Drew.Metadata.Metadata ReadMetadata(InputStream inputStream) { // TIFF processing requires random access, as directories can be scattered throughout the byte sequence. // InputStream does not support seeking backwards, and so is not a viable option for TIFF processing. // We use RandomAccessStreamReader, which buffers data from the stream as we seek forward. Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata(); new ExifReader().ExtractTiff(new RandomAccessStreamReader(inputStream), metadata); return metadata; }
/* /********************************************************** /* Public API /********************************************************** */ /// <exception cref="System.IO.IOException"/> public override void close() { Sharpen.InputStream @in = _in; if (@in != null) { _in = null; freeBuffers(); @in.close(); } }
public InputStreamBody(InputStream @in, string mimeType, string filename) : base( mimeType) { if (@in == null) { throw new ArgumentException("Input stream may not be null"); } this.@in = @in; this.filename = filename; }
protected internal DataFormatMatcher(Sharpen.InputStream @in, byte[] buffered, int bufferedStart, int bufferedLength, com.fasterxml.jackson.core.JsonFactory match , com.fasterxml.jackson.core.format.MatchStrength strength) { _originalStream = @in; _bufferedData = buffered; _bufferedStart = bufferedStart; _bufferedLength = bufferedLength; _match = match; _matchStrength = strength; }
/// <exception cref="System.IO.IOException"></exception> public static void CopyStream(InputStream @is, OutputStream os) { int n; byte[] buffer = new byte[16384]; while ((n = @is.Read(buffer)) > -1) { os.Write(buffer, 0, n); } os.Close(); @is.Close(); }
/// <exception cref="System.IO.IOException"></exception> public static void CopyStreamToFile(InputStream @is, FilePath file) { OutputStream os = new FileOutputStream(file); int n; byte[] buffer = new byte[16384]; while ((n = @is.Read(buffer)) > -1) { os.Write(buffer, 0, n); } os.Close(); @is.Close(); }
public RandomAccessStreamReader([NotNull] InputStream stream, int chunkLength) { if (stream == null) { throw new ArgumentNullException(); } if (chunkLength <= 0) { throw new ArgumentException("chunkLength must be greater than zero"); } _chunkLength = chunkLength; _stream = stream; }
public URLConnection(Uri url) : base(url) { responseInputStream = new PipedInputStream(); try { responseOutputStream = new PipedOutputStream((PipedInputStream)responseInputStream ); } catch (IOException e) { Log.E(Database.Tag, "Exception creating piped output stream", e); } }
/// <summary> /// Constructor used when content to check is available via /// input stream and must be read. /// </summary> public Std(Sharpen.InputStream @in, byte[] buffer) { /* /********************************************************** /* Standard implementation /********************************************************** */ _in = @in; _buffer = buffer; _bufferedStart = 0; _ptr = 0; _bufferedEnd = 0; }
/// <exception cref="System.IO.IOException"></exception> public static byte[] Read(InputStream @is) { int initialCapacity = 1024; ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(initialCapacity); byte[] bytes = new byte[512]; int offset = 0; int numRead = 0; while ((numRead = @is.Read(bytes, offset, bytes.Length - offset)) >= 0) { byteArrayBuffer.Append(bytes, 0, numRead); offset += numRead; } return byteArrayBuffer.ToByteArray(); }
public UTF32Reader(com.fasterxml.jackson.core.io.IOContext ctxt, Sharpen.InputStream @in, byte[] buf, int ptr, int len, bool isBigEndian) { /* /********************************************************** /* Life-cycle /********************************************************** */ _context = ctxt; _in = @in; _buffer = buf; _ptr = ptr; _length = len; _bigEndian = isBigEndian; _managedBuffers = (@in != null); }
/// <summary>Loads the stream into a buffer.</summary> /// <param name="in">an InputStream</param> /// <exception cref="System.IO.IOException">If the stream cannot be read.</exception> public ByteBuffer(InputStream @in) { // load stream into buffer int chunk = 16384; this.length = 0; this.buffer = new sbyte[chunk]; int read; while ((read = @in.Read(this.buffer, this.length, chunk)) > 0) { this.length += read; if (read == chunk) { EnsureCapacity(length + chunk); } else { break; } } }
public static void Load(this Hashtable props, InputStream stream) { using (var reader = new InputStreamReader(stream, Encoding.UTF8)) { while (!reader.EndOfStream) { var line = reader.ReadLine(); if (!String.IsNullOrWhiteSpace(line) && !line.StartsWith("#")) { var parts = line.Split('='); if (parts.Length != 2) throw new InvalidOperationException("Properties must be key value pairs separated by an '='."); if (!props.ContainsKey(parts[0])) props.Add(parts[0], parts[1]); else props[parts[0]] = parts[1]; } } } }
/// <exception cref="NGit.Errors.TransportException"></exception> internal BundleFetchConnection(NGit.Transport.Transport transportBundle, InputStream src) { transport = transportBundle; bin = new BufferedInputStream(src); try { switch (ReadSignature()) { case 2: { ReadBundleV2(); break; } default: { throw new TransportException(transport.uri, JGitText.Get().notABundle); } } } catch (TransportException err) { Close(); throw; } catch (IOException err) { Close(); throw new TransportException(transport.uri, err.Message, err); } catch (RuntimeException err) { Close(); throw new TransportException(transport.uri, err.Message, err); } }
/// <exception cref="EU.Europa.EC.Markt.Dss.CannotFetchDataException"></exception> public Stream Post(string URL, InputStream content) { try { LOG.Info("Post data to url " + URL); byte[] data = Streams.ReadAll(content); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Timeout = TimeOut; request.Method = "POST"; request.ContentLength = data.Length; if (ContentType != null) { request.ContentType = ContentType; } if (Accept != null) { request.Accept = Accept; } Stream dataStream = request.GetRequestStream(); dataStream.Write(data, 0, data.Length); dataStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); dataStream = response.GetResponseStream(); return dataStream; } catch (IOException ex) { throw new CannotFetchDataException(ex, URL); } }
/// <exception cref="System.IO.IOException"></exception> public override ObjectId Insert(int type, long len, InputStream @is) { MessageDigest md = Digest(); FilePath tmp = ToTemp(md, type, len, @is); ObjectId id = ObjectId.FromRaw(md.Digest()); switch (db.InsertUnpackedObject(tmp, id, false)) { case FileObjectDatabase.InsertLooseObjectResult.INSERTED: case FileObjectDatabase.InsertLooseObjectResult.EXISTS_PACKED: case FileObjectDatabase.InsertLooseObjectResult.EXISTS_LOOSE: { return id; } case FileObjectDatabase.InsertLooseObjectResult.FAILURE: default: { break; break; } } FilePath dst = db.FileFor(id); throw new ObjectWritingException("Unable to create new object: " + dst); }
/// <summary>Construct a delta application stream, reading instructions.</summary> /// <remarks>Construct a delta application stream, reading instructions.</remarks> /// <param name="deltaStream">the stream to read delta instructions from.</param> /// <exception cref="System.IO.IOException"> /// the delta instruction stream cannot be read, or is /// inconsistent with the the base object information. /// </exception> public DeltaStream(InputStream deltaStream) { this.deltaStream = deltaStream; if (!Fill(cmdbuf.Length)) { throw new EOFException(); } // Length of the base object. // int c; int shift = 0; do { c = cmdbuf[cmdptr++] & unchecked((int)(0xff)); baseSize |= ((long)(c & unchecked((int)(0x7f)))) << shift; shift += 7; } while ((c & unchecked((int)(0x80))) != 0); // Length of the resulting object. // shift = 0; do { c = cmdbuf[cmdptr++] & unchecked((int)(0xff)); resultSize |= ((long)(c & unchecked((int)(0x7f)))) << shift; shift += 7; } while ((c & unchecked((int)(0x80))) != 0); curcmd = Next(); }
public override void Close() { if (@out != null) { try { if (outNeedsEnd) { outNeedsEnd = false; pckOut.End(); } @out.Close(); } catch (IOException) { } finally { // Ignore any close errors. @out = null; pckOut = null; } } if (@in != null) { try { @in.Close(); } catch (IOException) { } finally { // Ignore any close errors. @in = null; pckIn = null; } } if (myTimer != null) { try { myTimer.Terminate(); } finally { myTimer = null; timeoutIn = null; timeoutOut = null; } } }
public WrappedSystemStream(InputStream ist) { this.ist = ist; }
/// <summary>Configure this connection with the directional pipes.</summary> /// <remarks>Configure this connection with the directional pipes.</remarks> /// <param name="myIn"> /// input stream to receive data from the peer. Caller must ensure /// the input is buffered, otherwise read performance may suffer. /// </param> /// <param name="myOut"> /// output stream to transmit data to the peer. Caller must ensure /// the output is buffered, otherwise write performance may /// suffer. /// </param> protected internal void Init(InputStream myIn, OutputStream myOut) { int timeout = transport.GetTimeout(); if (timeout > 0) { Sharpen.Thread caller = Sharpen.Thread.CurrentThread(); myTimer = new InterruptTimer(caller.GetName() + "-Timer"); timeoutIn = new TimeoutInputStream(myIn, myTimer); timeoutOut = new TimeoutOutputStream(myOut, myTimer); timeoutIn.SetTimeout(timeout * 1000); timeoutOut.SetTimeout(timeout * 1000); myIn = timeoutIn; myOut = timeoutOut; } @in = myIn; @out = myOut; pckIn = new PacketLineIn(@in); pckOut = new PacketLineOut(@out); outNeedsEnd = true; }
static internal InputStream Wrap (Stream s) { InputStream stream = new InputStream (); stream.Wrapped = s; return stream; }
/// <summary> /// Determine heuristically whether the bytes contained in a stream /// represents binary (as opposed to text) content. /// </summary> /// <remarks> /// Determine heuristically whether the bytes contained in a stream /// represents binary (as opposed to text) content. /// Note: Do not further use this stream after having called this method! The /// stream may not be fully read and will be left at an unknown position /// after consuming an unknown number of bytes. The caller is responsible for /// closing the stream. /// </remarks> /// <param name="raw">input stream containing the raw file content.</param> /// <returns>true if raw is likely to be a binary file, false otherwise</returns> /// <exception cref="System.IO.IOException">if input stream could not be read</exception> public static bool IsBinary(InputStream raw) { byte[] buffer = new byte[FIRST_FEW_BYTES]; int cnt = 0; while (cnt < buffer.Length) { int n = raw.Read(buffer, cnt, buffer.Length - cnt); if (n == -1) { break; } cnt += n; } return IsBinary(buffer, cnt); }
public DigestInputStream(InputStream stream, MessageDigest digest) : base(stream) { Digest = digest; }
/// <exception cref="System.IO.IOException"></exception> private void SeekBase() { if (baseStream == null) { baseStream = OpenBase(); if (GetBaseSize() != baseSize) { throw new CorruptObjectException(JGitText.Get().baseLengthIncorrect); } IOUtil.SkipFully(baseStream, copyOffset); baseOffset = copyOffset; } else { if (baseOffset < copyOffset) { IOUtil.SkipFully(baseStream, copyOffset - baseOffset); baseOffset = copyOffset; } else { if (baseOffset > copyOffset) { baseStream.Close(); baseStream = OpenBase(); IOUtil.SkipFully(baseStream, copyOffset); baseOffset = copyOffset; } } } }
/// <exception cref="System.IO.IOException"></exception> private PackParser Index(InputStream @in) { if (inserter == null) { inserter = db.NewObjectInserter(); } return inserter.NewPackParser(@in); }
public FilterInputStream(InputStream s) { this.@in = s; }