indexcopy.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: indexcopy.h,v 1.3 2001/05/27 04:46:54 jgg Exp $
  4. /* ######################################################################
  5. Index Copying - Aid for copying and verifying the index files
  6. ##################################################################### */
  7. /*}}}*/
  8. #ifndef INDEXCOPY_H
  9. #define INDEXCOPY_H
  10. #include <vector>
  11. #include <string>
  12. #include <stdio.h>
  13. #include <apt-pkg/gpgv.h>
  14. #include <apt-pkg/macros.h>
  15. #ifndef APT_8_CLEANER_HEADERS
  16. using std::string;
  17. using std::vector;
  18. #endif
  19. class pkgTagSection;
  20. class FileFd;
  21. class indexRecords;
  22. class pkgCdromStatus;
  23. class IndexCopy /*{{{*/
  24. {
  25. /** \brief dpointer placeholder (for later in case we need it) */
  26. void *d;
  27. protected:
  28. pkgTagSection *Section;
  29. std::string ChopDirs(std::string Path,unsigned int Depth);
  30. bool ReconstructPrefix(std::string &Prefix,std::string OrigPath,std::string CD,
  31. std::string File);
  32. bool ReconstructChop(unsigned long &Chop,std::string Dir,std::string File);
  33. void ConvertToSourceList(std::string CD,std::string &Path);
  34. bool GrabFirst(std::string Path,std::string &To,unsigned int Depth);
  35. virtual bool GetFile(std::string &Filename,unsigned long long &Size) = 0;
  36. virtual bool RewriteEntry(FILE *Target,std::string File) = 0;
  37. virtual const char *GetFileName() = 0;
  38. virtual const char *Type() = 0;
  39. public:
  40. bool CopyPackages(std::string CDROM,std::string Name,std::vector<std::string> &List,
  41. pkgCdromStatus *log);
  42. virtual ~IndexCopy() {};
  43. };
  44. /*}}}*/
  45. class PackageCopy : public IndexCopy /*{{{*/
  46. {
  47. protected:
  48. virtual bool GetFile(std::string &Filename,unsigned long long &Size);
  49. virtual bool RewriteEntry(FILE *Target,std::string File);
  50. virtual const char *GetFileName() {return "Packages";};
  51. virtual const char *Type() {return "Package";};
  52. };
  53. /*}}}*/
  54. class SourceCopy : public IndexCopy /*{{{*/
  55. {
  56. protected:
  57. virtual bool GetFile(std::string &Filename,unsigned long long &Size);
  58. virtual bool RewriteEntry(FILE *Target,std::string File);
  59. virtual const char *GetFileName() {return "Sources";};
  60. virtual const char *Type() {return "Source";};
  61. };
  62. /*}}}*/
  63. class TranslationsCopy /*{{{*/
  64. {
  65. protected:
  66. pkgTagSection *Section;
  67. public:
  68. bool CopyTranslations(std::string CDROM,std::string Name,std::vector<std::string> &List,
  69. pkgCdromStatus *log);
  70. };
  71. /*}}}*/
  72. class SigVerify /*{{{*/
  73. {
  74. /** \brief dpointer placeholder (for later in case we need it) */
  75. void *d;
  76. bool Verify(std::string prefix,std::string file, indexRecords *records);
  77. bool CopyMetaIndex(std::string CDROM, std::string CDName,
  78. std::string prefix, std::string file);
  79. public:
  80. bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
  81. std::vector<std::string> PkgList,std::vector<std::string> SrcList);
  82. __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
  83. int const &statusfd, int fd[2]);
  84. __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
  85. int const &statusfd = -1);
  86. };
  87. /*}}}*/
  88. #endif