indexcopy.h 3.2 KB

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