1
0
Fork 0
apt/test/interactive-helper/testdeb.cc
Daniel Baumann 6810ba718b
Adding upstream version 3.0.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-20 21:10:43 +02:00

51 lines
1.1 KiB
C++

#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:
bool DoItem(Item &/*Itm*/, int &/*Fd*/) 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;
}