extracttar.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 <apt-pkg/macros.h>
  15. #include <string>
  16. #ifndef APT_8_CLEANER_HEADERS
  17. #include <apt-pkg/dirstream.h>
  18. #include <algorithm>
  19. using std::min;
  20. #endif
  21. class pkgDirStream;
  22. class ExtractTar
  23. {
  24. protected:
  25. struct TarHeader;
  26. // The varios types items can be
  27. enum ItemType {NormalFile0 = '\0',NormalFile = '0',HardLink = '1',
  28. SymbolicLink = '2',CharacterDevice = '3',
  29. BlockDevice = '4',Directory = '5',FIFO = '6',
  30. GNU_LongLink = 'K',GNU_LongName = 'L'};
  31. FileFd &File;
  32. #if APT_PKG_ABI >= 413
  33. unsigned long long MaxInSize;
  34. #else
  35. unsigned long MaxInSize;
  36. #endif
  37. int GZPid;
  38. FileFd InFd;
  39. bool Eof;
  40. std::string DecompressProg;
  41. // Fork and reap gzip
  42. bool StartGzip();
  43. bool Done(bool Force);
  44. public:
  45. bool Go(pkgDirStream &Stream);
  46. #if APT_PKG_ABI >= 413
  47. ExtractTar(FileFd &Fd,unsigned long long Max,std::string DecompressionProgram);
  48. #else
  49. ExtractTar(FileFd &Fd,unsigned long Max,std::string DecompressionProgram);
  50. #endif
  51. virtual ~ExtractTar();
  52. };
  53. #endif