extracttar.h 1.4 KB

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