extracttar.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: extracttar.h,v 1.2 2001/02/20 07:03:17 jgg Exp $
  4. /* ######################################################################
  5. Extract a Tar - Tar Extractor
  6. The tar extractor takes an ordinary gzip compressed tar stream from
  7. the given file and explodes it, passing the individual items to the
  8. given Directory Stream for processing.
  9. ##################################################################### */
  10. /*}}}*/
  11. #ifndef PKGLIB_EXTRACTTAR_H
  12. #define PKGLIB_EXTRACTTAR_H
  13. #include <apt-pkg/fileutl.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(bool Force);
  39. public:
  40. bool Go(pkgDirStream &Stream);
  41. ExtractTar(FileFd &Fd,unsigned long long Max,std::string DecompressionProgram);
  42. virtual ~ExtractTar();
  43. };
  44. #endif