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.
 
 
 
 
 
 

52 lines
1.1 KiB

  1. #include <config.h>
  2. #include <apt-pkg/arfile.h>
  3. #include <apt-pkg/debfile.h>
  4. #include <apt-pkg/dirstream.h>
  5. #include <apt-pkg/error.h>
  6. #include <apt-pkg/extracttar.h>
  7. #include <apt-pkg/fileutl.h>
  8. #include <iostream>
  9. #include <string>
  10. class NullStream : public pkgDirStream
  11. {
  12. public:
  13. virtual bool DoItem(Item &/*Itm*/, int &/*Fd*/) APT_OVERRIDE {return true;};
  14. };
  15. static bool Test(const char *File)
  16. {
  17. FileFd Fd(File,FileFd::ReadOnly);
  18. debDebFile Deb(Fd);
  19. if (_error->PendingError() == true)
  20. return false;
  21. // Get the archive member and positition the file
  22. const ARArchive::Member *Member = Deb.GotoMember("data.tar.gz");
  23. if (Member == 0)
  24. return false;
  25. // Extract it.
  26. ExtractTar Tar(Deb.GetFile(),Member->Size, "gzip");
  27. NullStream Dir;
  28. if (Tar.Go(Dir) == false)
  29. return false;
  30. return true;
  31. }
  32. int main(int argc, const char *argv[])
  33. {
  34. if (argc != 2) {
  35. std::cout << "One parameter expected - given " << argc << std::endl;
  36. return 100;
  37. }
  38. Test(argv[1]);
  39. _error->DumpErrors();
  40. return 0;
  41. }