]> 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 cb272e3898a2b415960c9fa68f4cd8281e9c01d3..84ee4c124cf3c1c0c9c733f5a58e1aeca4e5f499 100644 (file)
@@ -8,9 +8,6 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/progress.h"
-#endif 
 #include <apt-pkg/progress.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
@@ -19,6 +16,7 @@
 
 #include <iostream>
 #include <stdio.h>
+#include <cstring>
                                                                        /*}}}*/
 
 using namespace std;
@@ -67,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;
-   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;
+   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;
+      this->Percent = Current*100.0/Total;
    Update();
 }
                                                                        /*}}}*/
@@ -115,6 +104,8 @@ bool OpProgress::CheckChange(float Interval)
    
    if ((int)LastPercent == (int)Percent)
       return false;
+
+   LastPercent = Percent;
    
    if (Interval == 0)
       return false;
@@ -126,7 +117,6 @@ bool OpProgress::CheckChange(float Interval)
    if (Diff < Interval)
       return false;
    LastTime = Now;   
-   LastPercent = Percent;
    return true;
 }
                                                                        /*}}}*/
@@ -136,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;