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.
 
 
 
 
 
 

61 lines
1.4 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Extract a Tar - Tar Extractor
  5. The tar extractor takes an ordinary gzip compressed tar stream from
  6. the given file and explodes it, passing the individual items to the
  7. given Directory Stream for processing.
  8. ##################################################################### */
  9. /*}}}*/
  10. #ifndef PKGLIB_EXTRACTTAR_H
  11. #define PKGLIB_EXTRACTTAR_H
  12. #include <apt-pkg/fileutl.h>
  13. #include <apt-pkg/macros.h>
  14. #include <string>
  15. #ifndef APT_8_CLEANER_HEADERS
  16. #include <apt-pkg/dirstream.h>
  17. #include <algorithm>
  18. using std::min;
  19. #endif
  20. class pkgDirStream;
  21. class ExtractTar
  22. {
  23. protected:
  24. struct TarHeader;
  25. // The varios types items can be
  26. enum ItemType {NormalFile0 = '\0',NormalFile = '0',HardLink = '1',
  27. SymbolicLink = '2',CharacterDevice = '3',
  28. BlockDevice = '4',Directory = '5',FIFO = '6',
  29. GNU_LongLink = 'K',GNU_LongName = 'L'};
  30. FileFd &File;
  31. unsigned long long MaxInSize;
  32. int GZPid;
  33. FileFd InFd;
  34. bool Eof;
  35. std::string DecompressProg;
  36. // Fork and reap gzip
  37. bool StartGzip();
  38. bool Done();
  39. public:
  40. bool Go(pkgDirStream &Stream);
  41. ExtractTar(FileFd &Fd,unsigned long long Max,std::string DecompressionProgram);
  42. virtual ~ExtractTar();
  43. };
  44. #endif