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