diff options
author | Michael Vogt <mvo@debian.org> | 2013-11-29 08:38:12 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-11-29 08:38:12 +0100 |
commit | faeb435cab7b41a50c621ef9f96853d15c57d0d8 (patch) | |
tree | c2554080ab4a46b0cfdd1eba7fb0767328e75c44 /apt-pkg/contrib/hashes.cc | |
parent | c1a61d1ca91e0a0a79b8c1be3fe04bcfa12cf0dc (diff) | |
parent | cf993341c2067ee091cfd51e5da0e237babce171 (diff) |
Merge branch 'feature/edit-sources' into debian/sid
Diffstat (limited to 'apt-pkg/contrib/hashes.cc')
-rw-r--r-- | apt-pkg/contrib/hashes.cc | 25 |
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() |