apt: apt-pkg/deb/debfile.h Source File

apt 2.9.8 commandline package manager

debfile.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Debian Archive File (.deb)
6
7 This Class handles all the operations performed directly on .deb
8 files. It makes use of the AR and TAR classes to give the necessary
9 external interface.
10
11 There are only two things that can be done with a raw package,
12 extract it's control information and extract the contents itself.
13
14 This should probably subclass an as-yet unwritten super class to
15 produce a generic archive mechanism.
16
17 The memory control file extractor is useful to extract a single file
18 into memory from the control.tar.gz
19
20 ##################################################################### */
21 /*}}}*/
22#ifndef PKGLIB_DEBFILE_H
23#define PKGLIB_DEBFILE_H
24
25#include <apt-pkg/arfile.h>
26#include <apt-pkg/dirstream.h>
27#include <apt-pkg/macros.h>
28#include <apt-pkg/tagfile.h>
29
30#include <string>
31
32
33class FileFd;
34
35 class APT_PUBLIC debDebFile
36{
37 protected:
38
39 FileFd &File;
40 ARArchive AR;
41
42 bool CheckMember(const char *Name);
43
44 public:
45 class ControlExtract;
46 class MemControlExtract;
47
48 bool ExtractTarMember(pkgDirStream &Stream, const char *Name);
49 bool ExtractArchive(pkgDirStream &Stream);
50 const ARArchive::Member *GotoMember(const char *Name);
51 inline FileFd &GetFile() {return File;};
52
53 explicit debDebFile(FileFd &File);
54};
55
56class APT_PUBLIC debDebFile::ControlExtract : public pkgDirStream
57{
58 public:
59
60 virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
61};
62
63class APT_PUBLIC debDebFile::MemControlExtract : public pkgDirStream
64{
65 bool IsControl;
66
67 public:
68
69 char *Control;
70 pkgTagSection Section;
71 unsigned long Length;
72 std::string Member;
73
74 // Members from DirStream
75 virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE;
76 virtual bool Process(Item &Itm,const unsigned char *Data,
77 unsigned long long Size,unsigned long long Pos) APT_OVERRIDE;
78
79 // Helpers
80 bool Read(debDebFile &Deb);
81 bool TakeControl(const void *Data,unsigned long long Size);
82
83 MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
84 explicit MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
85 ~MemControlExtract() {delete [] Control;};
86};
87 /*}}}*/
88
89#endif
ARArchive
Definition arfile.h:23
FileFd
Definition fileutl.h:41
debDebFile
Definition debfile.h:36
pkgDirStream
Definition dirstream.h:30
pkgTagSection
Definition tagfile.h:45
ARArchive::Member
Definition arfile.h:50