]> git.saurik.com Git - apt-legacy.git/blob - test/testdeb.cc
Support Architecture: cydia packages, for giggles.
[apt-legacy.git] / test / testdeb.cc
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:
9 virtual bool DoItem(Item &Itm,int &Fd) {return true;};
10 };
11
12 bool Test(const char *File)
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.
26 ExtractTar Tar(Deb.GetFile(),Member->Size, "gzip");
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 {
36 Test(argv[1]);
37 _error->DumpErrors();
38 return 0;
39 }