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