indexcopy.h 3.3 KB

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