]> git.saurik.com Git - apt.git/blob - apt-pkg/indexcopy.h
first version with test
[apt.git] / apt-pkg / indexcopy.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: indexcopy.h,v 1.3 2001/05/27 04:46:54 jgg Exp $
4 /* ######################################################################
5
6 Index Copying - Aid for copying and verifying the index files
7
8 ##################################################################### */
9 /*}}}*/
10 #ifndef INDEXCOPY_H
11 #define INDEXCOPY_H
12
13 #include <vector>
14 #include <string>
15 #include <stdio.h>
16
17 #include <apt-pkg/gpgv.h>
18 #include <apt-pkg/macros.h>
19
20 #ifndef APT_8_CLEANER_HEADERS
21 using std::string;
22 using std::vector;
23 #endif
24
25 class pkgTagSection;
26 class FileFd;
27 class indexRecords;
28 class pkgCdromStatus;
29
30 class IndexCopy /*{{{*/
31 {
32 /** \brief dpointer placeholder (for later in case we need it) */
33 void *d;
34
35 protected:
36
37 pkgTagSection *Section;
38
39 std::string ChopDirs(std::string Path,unsigned int Depth);
40 bool ReconstructPrefix(std::string &Prefix,std::string OrigPath,std::string CD,
41 std::string File);
42 bool ReconstructChop(unsigned long &Chop,std::string Dir,std::string File);
43 void ConvertToSourceList(std::string CD,std::string &Path);
44 bool GrabFirst(std::string Path,std::string &To,unsigned int Depth);
45 virtual bool GetFile(std::string &Filename,unsigned long long &Size) = 0;
46 virtual bool RewriteEntry(FILE *Target,std::string File) = 0;
47 virtual const char *GetFileName() = 0;
48 virtual const char *Type() = 0;
49
50 public:
51
52 bool CopyPackages(std::string CDROM,std::string Name,std::vector<std::string> &List,
53 pkgCdromStatus *log);
54 virtual ~IndexCopy() {};
55 };
56 /*}}}*/
57 class PackageCopy : public IndexCopy /*{{{*/
58 {
59 protected:
60
61 virtual bool GetFile(std::string &Filename,unsigned long long &Size);
62 virtual bool RewriteEntry(FILE *Target,std::string File);
63 virtual const char *GetFileName() {return "Packages";};
64 virtual const char *Type() {return "Package";};
65
66 };
67 /*}}}*/
68 class SourceCopy : public IndexCopy /*{{{*/
69 {
70 protected:
71
72 virtual bool GetFile(std::string &Filename,unsigned long long &Size);
73 virtual bool RewriteEntry(FILE *Target,std::string File);
74 virtual const char *GetFileName() {return "Sources";};
75 virtual const char *Type() {return "Source";};
76
77 };
78 /*}}}*/
79 class TranslationsCopy /*{{{*/
80 {
81 protected:
82 pkgTagSection *Section;
83
84 public:
85 bool CopyTranslations(std::string CDROM,std::string Name,std::vector<std::string> &List,
86 pkgCdromStatus *log);
87 };
88 /*}}}*/
89 class SigVerify /*{{{*/
90 {
91 /** \brief dpointer placeholder (for later in case we need it) */
92 void *d;
93
94 bool Verify(std::string prefix,std::string file, indexRecords *records);
95 bool CopyMetaIndex(std::string CDROM, std::string CDName,
96 std::string prefix, std::string file);
97
98 public:
99 bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
100 std::vector<std::string> PkgList,std::vector<std::string> SrcList);
101
102 __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
103 int const &statusfd, int fd[2]);
104 __deprecated static bool RunGPGV(std::string const &File, std::string const &FileOut,
105 int const &statusfd = -1);
106 };
107 /*}}}*/
108
109 #endif