Exemplo n.º 1
0
 private byte[] IdBufferBlob(WorkingTreeIterator.Entry e)
 {
     try
     {
         InputStream @is = e.OpenInputStream();
         if (@is == null)
         {
             return(zeroid);
         }
         try
         {
             state.InitializeDigestAndReadBuffer();
             long len = e.GetLength();
             if (!MightNeedCleaning())
             {
                 return(ComputeHash(@is, len));
             }
             if (len <= MAXIMUM_FILE_SIZE_TO_READ_FULLY)
             {
                 ByteBuffer rawbuf = IOUtil.ReadWholeStream(@is, (int)len);
                 byte[]     raw    = ((byte[])rawbuf.Array());
                 int        n      = rawbuf.Limit();
                 if (!IsBinary(raw, n))
                 {
                     rawbuf = FilterClean(raw, n);
                     raw    = ((byte[])rawbuf.Array());
                     n      = rawbuf.Limit();
                 }
                 return(ComputeHash(new ByteArrayInputStream(raw, 0, n), n));
             }
             if (IsBinary(e))
             {
                 return(ComputeHash(@is, len));
             }
             long        canonLen;
             InputStream lenIs = FilterClean(e.OpenInputStream());
             try
             {
                 canonLen = ComputeLength(lenIs);
             }
             finally
             {
                 SafeClose(lenIs);
             }
             return(ComputeHash(FilterClean(@is), canonLen));
         }
         finally
         {
             SafeClose(@is);
         }
     }
     catch (IOException)
     {
         // Can't read the file? Don't report the failure either.
         return(zeroid);
     }
 }
Exemplo n.º 2
0
        /// <exception cref="System.IO.IOException"></exception>
        private bool IsBinary(WorkingTreeIterator.Entry entry)
        {
            InputStream @in = entry.OpenInputStream();

            try
            {
                return(RawText.IsBinary(@in));
            }
            finally
            {
                SafeClose(@in);
            }
        }
Exemplo n.º 3
0
            /// <exception cref="System.IO.IOException"></exception>
            internal virtual IgnoreNode Load()
            {
                IgnoreNode  r   = new IgnoreNode();
                InputStream @in = entry.OpenInputStream();

                try
                {
                    r.Parse(@in);
                }
                finally
                {
                    @in.Close();
                }
                return(r.GetRules().IsEmpty() ? null : r);
            }