summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/hashsum.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-12-19 14:22:05 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-12-19 14:22:05 +0100
commit2f67d29b0c3de8618983055e811e70ee36662f4a (patch)
tree7ab0646d51474b4f3c16c8a984f2f1edd43528d8 /apt-pkg/contrib/hashsum.cc
parent27da8141d21cfbfc29675510737ee05bdfd4a2b1 (diff)
parent29966fd1cc2bab68777e85b9070dba7821a58d36 (diff)
merged from lp:~donkult/apt/experimental
Diffstat (limited to 'apt-pkg/contrib/hashsum.cc')
-rw-r--r--apt-pkg/contrib/hashsum.cc22
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;
+}
/*}}}*/