diff options
author | Guillem Jover <guillem@debian.org> | 2014-02-17 22:02:38 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2014-02-22 20:06:55 +0100 |
commit | 50b942e9a228337a2ca20931036c7cfd8cdba90d (patch) | |
tree | b923462863bf727482bd2a77c9e913020fa0da36 /apt-inst | |
parent | 3255db2d02358e0026c3e6d0d8cc1519bcd48faf (diff) |
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.
Diffstat (limited to 'apt-inst')
-rw-r--r-- | apt-inst/deb/debfile.cc | 17 | ||||
-rw-r--r-- | apt-inst/deb/debfile.h | 1 |
2 files changed, 13 insertions, 5 deletions
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<APT::Configuration::Compressor> compressor = APT::Configuration::getCompressors(); for (std::vector<APT::Configuration::Compressor>::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<APT::Configuration::Compressor>::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;}; |