]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/progress.cc
enable Hashes::AddFD() to skip creation of certain hashes
[apt.git] / apt-pkg / contrib / progress.cc
index 6ce6e950a788a90d603ac693ac215113c8b43cb6..84ee4c124cf3c1c0c9c733f5a58e1aeca4e5f499 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <iostream>
 #include <stdio.h>
+#include <cstring>
                                                                        /*}}}*/
 
 using namespace std;
@@ -64,27 +65,18 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
 // OpProgress::SubProgress - Set the sub progress state                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void OpProgress::SubProgress(unsigned long SubTotal,const string &Op)
+void OpProgress::SubProgress(unsigned long SubTotal,const string &Op,
+                            float const Percent)
 {
    this->SubTotal = SubTotal;
-   SubOp = Op;
-   if (Total == 0)
-      Percent = 0;
+   if (Op.empty() == false)
+      SubOp = Op;
+   if (Total == 0 || Percent == 0)
+      this->Percent = 0;
+   else if (Percent != -1)
+      this->Percent = this->Current += (Size*Percent)/SubTotal;
    else
-      Percent = Current*100.0/Total;
-   Update();
-}
-                                                                       /*}}}*/
-// OpProgress::SubProgress - Set the sub progress state                        /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-void OpProgress::SubProgress(unsigned long SubTotal)
-{
-   this->SubTotal = SubTotal;
-   if (Total == 0)
-      Percent = 0;
-   else
-      Percent = Current*100.0/Total;
+      this->Percent = Current*100.0/Total;
    Update();
 }
                                                                        /*}}}*/
@@ -134,7 +126,7 @@ bool OpProgress::CheckChange(float Interval)
 OpTextProgress::OpTextProgress(Configuration &Config) : 
                                NoUpdate(false), NoDisplay(false), LastLen(0) 
 {
-   if (Config.FindI("quiet",0) >= 1)
+   if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true)
       NoUpdate = true;
    if (Config.FindI("quiet",0) >= 2)
       NoDisplay = true;