]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/hashes.cc
Merge branch 'debian/sid' into feature/apt-manpage
[apt.git] / apt-pkg / contrib / hashes.cc
index e1a4318235a8291bf30248fefabd7c8763ab10e4..b4c768db97d193e1c4dc01926341c52105cc3287 100644 (file)
@@ -54,6 +54,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;
 
@@ -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()