aptmethod.h 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef APT_APTMETHOD_H
  2. #define APT_APTMETHOD_H
  3. #include <apt-pkg/acquire-method.h>
  4. #include <apt-pkg/configuration.h>
  5. #include <string>
  6. class aptMethod : public pkgAcqMethod
  7. {
  8. char const * const Binary;
  9. public:
  10. virtual bool Configuration(std::string Message) APT_OVERRIDE
  11. {
  12. if (pkgAcqMethod::Configuration(Message) == false)
  13. return false;
  14. std::string const conf = std::string("Binary::") + Binary;
  15. _config->MoveSubTree(conf.c_str(), NULL);
  16. DropPrivsOrDie();
  17. return true;
  18. }
  19. bool CalculateHashes(FetchItem const * const Itm, FetchResult &Res) const
  20. {
  21. Hashes Hash(Itm->ExpectedHashes);
  22. FileFd Fd;
  23. if (Fd.Open(Res.Filename, FileFd::ReadOnly) == false || Hash.AddFD(Fd) == false)
  24. return false;
  25. Res.TakeHashes(Hash);
  26. return true;
  27. }
  28. aptMethod(char const * const Binary, char const * const Ver, unsigned long const Flags) :
  29. pkgAcqMethod(Ver, Flags), Binary(Binary)
  30. {}
  31. };
  32. #endif