/// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="NGit.Errors.MissingObjectException"></exception>
 private void EnsureLoaded()
 {
     if (!IsLoaded())
     {
         ObjectLoader ldr = db.Open(GetId(), Constants.OBJ_TREE);
         ReadTree(ldr.GetCachedBytes());
     }
 }
		/// <exception cref="System.IO.IOException"></exception>
		private void Copy(TemporaryBuffer.Heap tinyPack, ObjectLoader ldr)
		{
			byte[] buf = new byte[64];
			byte[] content = ldr.GetCachedBytes();
			int dataLength = content.Length;
			int nextLength = (int)(((uint)dataLength) >> 4);
			int size = 0;
			buf[size++] = unchecked((byte)((nextLength > 0 ? unchecked((int)(0x80)) : unchecked(
				(int)(0x00))) | (ldr.GetType() << 4) | (dataLength & unchecked((int)(0x0F)))));
			dataLength = nextLength;
			while (dataLength > 0)
			{
				nextLength = (int)(((uint)nextLength) >> 7);
				buf[size++] = unchecked((byte)((nextLength > 0 ? unchecked((int)(0x80)) : unchecked(
					(int)(0x00))) | (dataLength & unchecked((int)(0x7F)))));
				dataLength = nextLength;
			}
			tinyPack.Write(buf, 0, size);
			Deflate(tinyPack, content);
		}
Beispiel #3
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private static byte[] Read(ObjectReader or, AnyObjectId blobId)
        {
            ObjectLoader loader = or.Open(blobId, Constants.OBJ_BLOB);

            return(loader.GetCachedBytes(int.MaxValue));
        }
Beispiel #4
0
 /// <summary>Create the stream from an existing loader's cached bytes.</summary>
 /// <remarks>Create the stream from an existing loader's cached bytes.</remarks>
 /// <param name="loader">the loader.</param>
 public SmallStream(ObjectLoader loader) : this(loader.GetType(), loader.GetCachedBytes
                                                    ())
 {
 }
Beispiel #5
0
		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="NGit.Diff.SimilarityIndex.TableFullException"></exception>
		internal virtual void Hash(ObjectLoader obj)
		{
			if (obj.IsLarge())
			{
				ObjectStream @in = obj.OpenStream();
				try
				{
					SetFileSize(@in.GetSize());
					Hash(@in, fileSize);
				}
				finally
				{
					@in.Close();
				}
			}
			else
			{
				byte[] raw = obj.GetCachedBytes();
				SetFileSize(raw.Length);
				Hash(raw, 0, raw.Length);
			}
		}
Beispiel #6
0
            /// <summary>Create the stream from an existing loader's cached bytes.</summary>
            /// <remarks>Create the stream from an existing loader's cached bytes.</remarks>
            /// <param name="loader">the loader.</param>
            public SmallStream(ObjectLoader loader)
                : this(loader.GetType(), loader.GetCachedBytes
				())
            {
            }