+// CacheDB::GetSHA1 - Get the SHA1 hash /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool CacheDB::GetSHA1(bool const &GenOnly)
+{
+ // Try to read the control information out of the DB.
+ if ((CurStat.Flags & FlSHA1) == FlSHA1)
+ {
+ if (GenOnly == true)
+ return true;
+
+ SHA1Res = bytes2hex(CurStat.SHA1, sizeof(CurStat.SHA1));
+ return true;
+ }
+
+ Stats.SHA1Bytes += CurStat.FileSize;
+
+ if (Fd == NULL && OpenFile() == false)
+ {
+ return false;
+ }
+ SHA1Summation SHA1;
+ if (Fd->Seek(0) == false || SHA1.AddFD(Fd->Fd(),CurStat.FileSize) == false)
+ return false;
+
+ SHA1Res = SHA1.Result();
+ hex2bytes(CurStat.SHA1, SHA1Res.data(), sizeof(CurStat.SHA1));
+ CurStat.Flags |= FlSHA1;
+ return true;
+}
+ /*}}}*/
+// CacheDB::GetSHA256 - Get the SHA256 hash /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool CacheDB::GetSHA256(bool const &GenOnly)
+{
+ // Try to read the control information out of the DB.
+ if ((CurStat.Flags & FlSHA256) == FlSHA256)
+ {
+ if (GenOnly == true)
+ return true;
+
+ SHA256Res = bytes2hex(CurStat.SHA256, sizeof(CurStat.SHA256));
+ return true;
+ }
+
+ Stats.SHA256Bytes += CurStat.FileSize;
+
+ if (Fd == NULL && OpenFile() == false)
+ {
+ return false;
+ }
+ SHA256Summation SHA256;
+ if (Fd->Seek(0) == false || SHA256.AddFD(Fd->Fd(),CurStat.FileSize) == false)
+ return false;
+
+ SHA256Res = SHA256.Result();
+ hex2bytes(CurStat.SHA256, SHA256Res.data(), sizeof(CurStat.SHA256));
+ CurStat.Flags |= FlSHA256;
+ return true;
+}
+ /*}}}*/