blob: 6aae9f563e5cba2e0dd6b8dad441e1f79521be65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <config.h>
#include <apt-pkg/dirstream.h>
#include <apt-pkg/debfile.h>
#include <apt-pkg/error.h>
#include <apt-pkg/extracttar.h>
#include <apt-pkg/arfile.h>
#include <apt-pkg/fileutl.h>
#include <iostream>
#include <string>
class NullStream : public pkgDirStream
{
public:
virtual bool DoItem(Item &/*Itm*/, int &/*Fd*/) {return true;};
};
static bool Test(const char *File)
{
FileFd Fd(File,FileFd::ReadOnly);
debDebFile Deb(Fd);
if (_error->PendingError() == true)
return false;
// Get the archive member and positition the file
const ARArchive::Member *Member = Deb.GotoMember("data.tar.gz");
if (Member == 0)
return false;
// Extract it.
ExtractTar Tar(Deb.GetFile(),Member->Size, "gzip");
NullStream Dir;
if (Tar.Go(Dir) == false)
return false;
return true;
}
int main(int argc, const char *argv[])
{
if (argc != 2) {
std::cout << "One parameter expected - given " << argc << std::endl;
return 100;
}
Test(argv[1]);
_error->DumpErrors();
return 0;
}
|