indexcopy.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. protected:
  22. pkgTagSection *Section;
  23. string ChopDirs(string Path,unsigned int Depth);
  24. bool ReconstructPrefix(string &Prefix,string OrigPath,string CD,
  25. string File);
  26. bool ReconstructChop(unsigned long &Chop,string Dir,string File);
  27. void ConvertToSourceList(string CD,string &Path);
  28. bool GrabFirst(string Path,string &To,unsigned int Depth);
  29. virtual bool GetFile(string &Filename,unsigned long &Size) = 0;
  30. virtual bool RewriteEntry(FILE *Target,string File) = 0;
  31. virtual const char *GetFileName() = 0;
  32. virtual const char *Type() = 0;
  33. public:
  34. bool CopyPackages(string CDROM,string Name,vector<string> &List,
  35. pkgCdromStatus *log);
  36. virtual ~IndexCopy() {};
  37. };
  38. class PackageCopy : public IndexCopy
  39. {
  40. protected:
  41. virtual bool GetFile(string &Filename,unsigned long &Size);
  42. virtual bool RewriteEntry(FILE *Target,string File);
  43. virtual const char *GetFileName() {return "Packages";};
  44. virtual const char *Type() {return "Package";};
  45. public:
  46. };
  47. class SourceCopy : public IndexCopy
  48. {
  49. protected:
  50. virtual bool GetFile(string &Filename,unsigned long &Size);
  51. virtual bool RewriteEntry(FILE *Target,string File);
  52. virtual const char *GetFileName() {return "Sources";};
  53. virtual const char *Type() {return "Source";};
  54. public:
  55. };
  56. class SigVerify
  57. {
  58. bool Verify(string prefix,string file, indexRecords *records);
  59. bool CopyMetaIndex(string CDROM, string CDName,
  60. string prefix, string file);
  61. public:
  62. bool CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
  63. vector<string> PkgList,vector<string> SrcList);
  64. };
  65. #endif