You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sources.cc 1.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <sstream>
  2. #include <string>
  3. // for memcpy
  4. #include <cstring>
  5. #include <apt-pkg/error.h>
  6. #include <apt-pkg/gpgv.h>
  7. #include "sources.h"
  8. bool DscExtract::TakeDsc(const void *newData, unsigned long long newSize)
  9. {
  10. if (newSize == 0)
  11. {
  12. // adding two newlines 'off record' for pkgTagSection.Scan() calls
  13. Data = "\n\n";
  14. Length = 0;
  15. return true;
  16. }
  17. Data = std::string((const char*)newData, newSize);
  18. // adding two newlines 'off record' for pkgTagSection.Scan() calls
  19. Data.append("\n\n");
  20. Length = newSize;
  21. return true;
  22. }
  23. bool DscExtract::Read(std::string FileName)
  24. {
  25. Data.clear();
  26. Length = 0;
  27. FileFd F;
  28. if (OpenMaybeClearSignedFile(FileName, F) == false)
  29. return false;
  30. IsClearSigned = (FileName != F.Name());
  31. std::ostringstream data;
  32. char buffer[1024];
  33. do {
  34. unsigned long long actual = 0;
  35. if (F.Read(buffer, sizeof(buffer)-1, &actual) == false)
  36. return _error->Errno("read", "Failed to read dsc file %s", FileName.c_str());
  37. if (actual == 0)
  38. break;
  39. Length += actual;
  40. buffer[actual] = '\0';
  41. data << buffer;
  42. } while(true);
  43. // adding two newlines 'off record' for pkgTagSection.Scan() calls
  44. data << "\n\n";
  45. Data = data.str();
  46. return true;
  47. }