summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/hashes.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-11-29 14:39:27 +0100
committerMichael Vogt <mvo@debian.org>2013-11-29 14:39:27 +0100
commite2264d3f957694e229a9f6976fc136b8f82ad770 (patch)
treec1f0b9c64d1d60defe5ce1a89c6bc136d758a772 /apt-pkg/contrib/hashes.cc
parentfd4e73c33c20873af670ee40b549c46ee0d50801 (diff)
parentc9a5f74bd57fa4fcf4e30cade8e48c5635448689 (diff)
Merge branch 'debian/sid' into ubuntu/master
Conflicts: debian/changelog
Diffstat (limited to 'apt-pkg/contrib/hashes.cc')
-rw-r--r--apt-pkg/contrib/hashes.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index e1a431823..b4c768db9 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -55,6 +55,26 @@ HashString::HashString(std::string StringedHash) /*{{{*/
/*}}}*/
bool HashString::VerifyFile(std::string filename) const /*{{{*/
{
+ std::string fileHash = GetHashForFile(filename);
+
+ if(_config->FindB("Debug::Hashes",false) == true)
+ std::clog << "HashString::VerifyFile: got: " << fileHash << " expected: " << toStr() << std::endl;
+
+ return (fileHash == Hash);
+}
+ /*}}}*/
+bool HashString::FromFile(std::string filename) /*{{{*/
+{
+ // pick the strongest hash
+ if (Type == "")
+ Type = _SupportedHashes[0];
+
+ Hash = GetHashForFile(filename);
+ return true;
+}
+ /*}}}*/
+std::string HashString::GetHashForFile(std::string filename) const /*{{{*/
+{
std::string fileHash;
FileFd Fd(filename, FileFd::ReadOnly);
@@ -84,10 +104,7 @@ bool HashString::VerifyFile(std::string filename) const /*{{{*/
}
Fd.Close();
- if(_config->FindB("Debug::Hashes",false) == true)
- std::clog << "HashString::VerifyFile: got: " << fileHash << " expected: " << toStr() << std::endl;
-
- return (fileHash == Hash);
+ return fileHash;
}
/*}}}*/
const char** HashString::SupportedHashes()