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