diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-05 20:20:24 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-05 20:20:24 +0100 |
commit | 570590c0640f71c98893051420517894be8eb6eb (patch) | |
tree | 563eeacf3aa349c1c7366c073cfb99348ab1c6a8 /apt-pkg/contrib/hashsum.cc | |
parent | b7c7eb099c8d228935f9c3fa0a7c788a4018bfb1 (diff) | |
parent | 5c6ceb4557cb6497dea827d1ec4e2615ccd53e50 (diff) |
merged from debian-experimental2
Diffstat (limited to 'apt-pkg/contrib/hashsum.cc')
-rw-r--r-- | apt-pkg/contrib/hashsum.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index ff3b112bb..289e43aa4 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -25,4 +25,26 @@ bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) { } return true; } +bool SummationImplementation::AddFD(FileFd &Fd, unsigned long long Size) { + unsigned char Buf[64 * 64]; + bool ToEOF = (Size == 0); + while (Size != 0 || ToEOF) + { + unsigned long long n = sizeof(Buf); + if (!ToEOF) n = std::min(Size, n); + unsigned long long a = 0; + if (Fd.Read(Buf, n, &a) == false) // error + return false; + if (ToEOF == false) + { + if (a != n) // short read + return false; + } + else if (a == 0) // EOF + break; + Size -= a; + Add(Buf, a); + } + return true; +} /*}}}*/ |