diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 09:59:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 09:59:37 +0000 |
commit | 76e2632459410dec81337edb6a9fee33c9a660f3 (patch) | |
tree | a73345df208eede4a4daad340515c9328f34625c /test/interactive-helper/testdeb.cc | |
parent | Initial commit. (diff) | |
download | apt-76e2632459410dec81337edb6a9fee33c9a660f3.tar.xz apt-76e2632459410dec81337edb6a9fee33c9a660f3.zip |
Adding upstream version 2.7.12.upstream/2.7.12
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/interactive-helper/testdeb.cc')
-rw-r--r-- | test/interactive-helper/testdeb.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/interactive-helper/testdeb.cc b/test/interactive-helper/testdeb.cc new file mode 100644 index 0000000..0bb24a5 --- /dev/null +++ b/test/interactive-helper/testdeb.cc @@ -0,0 +1,51 @@ +#include <config.h> + +#include <apt-pkg/arfile.h> +#include <apt-pkg/debfile.h> +#include <apt-pkg/dirstream.h> +#include <apt-pkg/error.h> +#include <apt-pkg/extracttar.h> +#include <apt-pkg/fileutl.h> + +#include <iostream> +#include <string> + +class NullStream : public pkgDirStream +{ + public: + virtual bool DoItem(Item &/*Itm*/, int &/*Fd*/) APT_OVERRIDE {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; +} |