/// <exception cref="System.IO.IOException"></exception>
		internal override void Write(PackOutputStream @out, long pos, int cnt)
		{
			ByteBuffer s = buffer.Slice();
			s.Position((int)(pos - start));
			while (0 < cnt)
			{
				byte[] buf = @out.GetCopyBuffer();
				int n = Math.Min(cnt, buf.Length);
				s.Get(buf, 0, n);
				@out.Write(buf, 0, n);
				cnt -= n;
			}
		}
Esempio n. 2
0
		/// <exception cref="System.IO.IOException"></exception>
		public void WriteObjects(PackOutputStream @out, Iterable<ObjectToPack> list)
		{
			foreach (ObjectToPack otp in list)
			{
				@out.WriteObject(otp);
			}
		}
Esempio n. 3
0
		/// <exception cref="System.IO.IOException"></exception>
		internal override void Write(PackOutputStream @out, long pos, int cnt, MessageDigest
			 digest)
		{
			int ptr = (int)(pos - start);
			@out.Write(array, ptr, cnt);
			if (digest != null)
			{
				digest.Update(array, ptr, cnt);
			}
		}
Esempio n. 4
0
		/// <exception cref="System.IO.IOException"></exception>
		internal void CopyPackAsIs(PackFile pack, long length, bool validate, PackOutputStream
			 @out)
		{
			MessageDigest md = null;
			if (validate)
			{
				md = Constants.NewMessageDigest();
				byte[] buf = @out.GetCopyBuffer();
				Pin(pack, 0);
				if (window.Copy(0, buf, 0, 12) != 12)
				{
					pack.SetInvalid();
					throw new IOException(JGitText.Get().packfileIsTruncated);
				}
				md.Update(buf, 0, 12);
			}
			long position = 12;
			long remaining = length - (12 + 20);
			while (0 < remaining)
			{
				Pin(pack, position);
				int ptr = (int)(position - window.start);
				int n = (int)Math.Min(window.Size() - ptr, remaining);
				window.Write(@out, position, n, md);
				position += n;
				remaining -= n;
			}
			if (md != null)
			{
				byte[] buf = new byte[20];
				byte[] actHash = md.Digest();
				Pin(pack, position);
				if (window.Copy(position, buf, 0, 20) != 20)
				{
					pack.SetInvalid();
					throw new IOException(JGitText.Get().packfileIsTruncated);
				}
				if (!Arrays.Equals(actHash, buf))
				{
					pack.SetInvalid();
					throw new IOException(MessageFormat.Format(JGitText.Get().packfileCorruptionDetected
						, pack.GetPackFile().GetPath()));
				}
			}
		}
Esempio n. 5
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="NGit.Errors.StoredObjectRepresentationNotAvailableException"></exception>
		public void CopyObjectAsIs(PackOutputStream @out, ObjectToPack otp)
		{
			LocalObjectToPack src = (LocalObjectToPack)otp;
			src.pack.CopyAsIs(@out, src, this);
		}
Esempio n. 6
0
		/// <exception cref="System.IO.IOException"></exception>
		internal abstract void Write(PackOutputStream @out, long pos, int cnt, MessageDigest
			 md);
Esempio n. 7
0
		/// <exception cref="System.IO.IOException"></exception>
		public void CopyPackAsIs(PackOutputStream @out, CachedPack pack, bool validate)
		{
			((LocalCachedPack)pack).CopyAsIs(@out, validate, this);
		}
		/// <exception cref="System.IO.IOException"></exception>
		internal override void Write(PackOutputStream @out, long pos, int cnt)
		{
			@out.Write(array, (int)(pos - start), cnt);
		}
Esempio n. 9
0
		/// <exception cref="System.IO.IOException"></exception>
		internal virtual void CopyAsIs(PackOutputStream @out, bool validate, WindowCursor
			 wc)
		{
			foreach (PackFile pack in GetPacks())
			{
				pack.CopyPackAsIs(@out, validate, wc);
			}
		}
Esempio n. 10
0
		/// <exception cref="System.IO.IOException"></exception>
		internal abstract void Write(PackOutputStream @out, long pos, int cnt);
Esempio n. 11
0
		/// <exception cref="System.IO.IOException"></exception>
		internal void CopyPackAsIs(PackFile pack, PackOutputStream @out, long position, long
			 cnt)
		{
			while (0 < cnt)
			{
				Pin(pack, position);
				int ptr = (int)(position - window.start);
				int n = (int)Math.Min(window.Size() - ptr, cnt);
				window.Write(@out, position, n);
				position += n;
				cnt -= n;
			}
		}
Esempio n. 12
0
		/// <exception cref="System.IO.IOException"></exception>
		public void CopyPackAsIs(PackOutputStream @out, CachedPack pack)
		{
			((LocalCachedPack)pack).CopyAsIs(@out, this);
		}