summaryrefslogtreecommitdiff
path: root/test/interactive-helper/testdeb.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-09-14 13:22:19 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-09-14 13:22:19 +0200
commita0e07f3ec885c12c733c12805391646c202f3f31 (patch)
treefaa658f29d7dff42c6ed475037dd462384eab46e /test/interactive-helper/testdeb.cc
parentb11fe392b2245354591296df88c3be2e6218af12 (diff)
parentafd7b358f94efddb83a2911ec1a21e7280074b1e (diff)
merged from lp:~donkult/apt/experimental
Diffstat (limited to 'test/interactive-helper/testdeb.cc')
-rw-r--r--test/interactive-helper/testdeb.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/interactive-helper/testdeb.cc b/test/interactive-helper/testdeb.cc
new file mode 100644
index 000000000..d28f20114
--- /dev/null
+++ b/test/interactive-helper/testdeb.cc
@@ -0,0 +1,39 @@
+#include <apt-pkg/dirstream.h>
+#include <apt-pkg/debfile.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/extracttar.h>
+
+class NullStream : public pkgDirStream
+{
+ public:
+ virtual bool DoItem(Item &Itm,int &Fd) {return true;};
+};
+
+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[])
+{
+ Test(argv[1]);
+ _error->DumpErrors();
+ return 0;
+}