extracttar.h 1.3 KB

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