]> git.saurik.com Git - apt.git/commitdiff
DebFile: Refactor ExtractTarMember() out from ExtractArchive()
authorGuillem Jover <guillem@debian.org>
Mon, 17 Feb 2014 21:02:38 +0000 (22:02 +0100)
committerMichael Vogt <mvo@debian.org>
Sat, 22 Feb 2014 19:06:55 +0000 (20:06 +0100)
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
apt-inst/deb/debfile.h

index 79434d8b563c06b1ac3e0929d843ae644ee90ade..15db1a7fcb6ca54b7c924b2d338811aada8805be 100644 (file)
@@ -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            /*{{{*/
 // ---------------------------------------------------------------------
index 38211fb0f9ee5c0bb8450cca1a02d8732c1d667e..ecef71d2187c455afc47aeebe3f4c1664d79a514 100644 (file)
@@ -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;};