indexcopy.h 3.0 KB

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