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