indexcopy.h 3.3 KB

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