indexcopy.h 3.2 KB

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