From 50b942e9a228337a2ca20931036c7cfd8cdba90d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 17 Feb 2014 22:02:38 +0100 Subject: DebFile: Refactor ExtractTarMember() out from ExtractArchive() Generalize DebFile::ExtractArchive() to take a member base name, so that we can reuse it for control.tar member extraction too. --- apt-inst/deb/debfile.cc | 17 ++++++++++++----- apt-inst/deb/debfile.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index 79434d8b5..15db1a7fc 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -88,21 +88,20 @@ const ARArchive::Member *debDebFile::GotoMember(const char *Name) return Member; } /*}}}*/ -// DebFile::ExtractArchive - Extract the archive data itself /*{{{*/ +// DebFile::ExtractTarMember - Extract the contents of a tar member /*{{{*/ // --------------------------------------------------------------------- /* Simple wrapper around tar.. */ -bool debDebFile::ExtractArchive(pkgDirStream &Stream) +bool debDebFile::ExtractTarMember(pkgDirStream &Stream,const char *Name) { // Get the archive member const ARArchive::Member *Member = NULL; std::string Compressor; - std::string const data = "data.tar"; std::vector compressor = APT::Configuration::getCompressors(); for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) { - Member = AR.FindMember(std::string(data).append(c->Extension).c_str()); + Member = AR.FindMember(std::string(Name).append(c->Extension).c_str()); if (Member == NULL) continue; Compressor = c->Binary; @@ -111,7 +110,7 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream) if (Member == NULL) { - std::string ext = "data.tar.{"; + std::string ext = std::string(Name) + ".{"; for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) ext.append(c->Extension.substr(1)); @@ -129,6 +128,14 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream) return Tar.Go(Stream); } /*}}}*/ +// DebFile::ExtractArchive - Extract the archive data itself /*{{{*/ +// --------------------------------------------------------------------- +/* Simple wrapper around DebFile::ExtractTarMember. */ +bool debDebFile::ExtractArchive(pkgDirStream &Stream) +{ + return ExtractTarMember(Stream, "data.tar"); +} + /*}}}*/ // DebFile::ControlExtract::DoItem - Control Tar Extraction /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-inst/deb/debfile.h b/apt-inst/deb/debfile.h index 38211fb0f..ecef71d21 100644 --- a/apt-inst/deb/debfile.h +++ b/apt-inst/deb/debfile.h @@ -48,6 +48,7 @@ class debDebFile class ControlExtract; class MemControlExtract; + bool ExtractTarMember(pkgDirStream &Stream, const char *Name); bool ExtractArchive(pkgDirStream &Stream); const ARArchive::Member *GotoMember(const char *Name); inline FileFd &GetFile() {return File;}; -- cgit v1.2.3