apt 3.2.0 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
33 class 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
56 class APT_PUBLIC debDebFile::ControlExtract : public pkgDirStream
57{
58 public:
59 bool DoItem(Item &Itm, int &Fd) override;
60};
61
62 class APT_PUBLIC debDebFile::MemControlExtract : public pkgDirStream
63{
64 bool IsControl;
65
66 public:
67
68 char *Control;
69 pkgTagSection Section;
70 unsigned long Length;
71 std::string Member;
72
73 // Members from DirStream
74 bool DoItem(Item &Itm, int &Fd) override;
75 bool Process(Item &Itm, const unsigned char *Data,
76 unsigned long long Size, unsigned long long Pos) override;
77
78 // Helpers
79 bool Read(debDebFile &Deb);
80 bool TakeControl(const void *Data,unsigned long long Size);
81
82 MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {};
83 explicit MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {};
84 ~MemControlExtract() override { delete[] Control; };
85};
86 /*}}}*/
87
88#endif
ARArchive
Definition arfile.h:23
FileFd
Definition fileutl.h:43
debDebFile::ControlExtract
Definition debfile.h:57
debDebFile::MemControlExtract
Definition debfile.h:63
pkgDirStream
Definition dirstream.h:30
pkgTagSection
Definition tagfile.h:46
ARArchive::Member
Definition arfile.h:50
pkgDirStream::Item
Definition dirstream.h:35