]> gitweb.hamatoma.de Git - crepublib/commitdiff
ReDirTool corrections
authorkawi <winfriedkappeler@atron.de>
Fri, 2 Jan 2015 00:25:10 +0000 (01:25 +0100)
committerkawi <winfriedkappeler@atron.de>
Fri, 2 Jan 2015 00:25:10 +0000 (01:25 +0100)
os/DirTools.hpp
os/ReDirTools.cpp

index f714b94b8ecaf8142540e48f9be2dab8ab957a2c..9f210b8a5a21022558032db37bf15ac89530c7b1 100644 (file)
@@ -40,8 +40,13 @@ public:
        const ReStringList& calculate(const char* base, int depth,
                                void (*format)(const ReDirStatisticData& data, ReDirStatistic& parent,
                                        ReByteBuffer& line) = formatLikeDu);
+    void setTraceInterval(int interval){
+        m_traceInterval = interval;
+    }
 private:
        ReStringList m_list;
+    int m_traceInterval;
+    time_t m_lastTrace;
 };
 
 
index de84c4232a1a9d01c766e99393b56b02f0274462..f395fa64b8c7f93d58ba10c3cd68ad7f8f62f910 100644 (file)
@@ -70,7 +70,9 @@ ReDirStatisticData& ReDirStatisticData::add(const ReDirStatisticData& source){
  * Constructor.
  */
 ReDirStatistic::ReDirStatistic(int deltaList, int deltaBuffer) :
-       m_list(deltaList, deltaBuffer)
+       m_list(deltaList, deltaBuffer),
+    m_traceInterval(0),
+    m_lastTrace(0)
 {
 }
 /**
@@ -103,6 +105,7 @@ const ReStringList& ReDirStatistic::calculate(const char* base, int level,
        ReDirStatisticData* current = dataStack[0];
        current->m_path.set(base, -1);
        ReByteBuffer line;
+    int traceCount = 0;
        while( (entry = traverser.rawNextFile(currentDepth))){
                if (currentDepth <= level && ! entry->m_path.equals(current->m_path)){
                        if (currentDepth <= topOfStack){
@@ -140,6 +143,14 @@ const ReStringList& ReDirStatistic::calculate(const char* base, int level,
                } else {
                        current->m_sizes += entry->fileSize();
                        current->m_files++;
+            if (++traceCount % 100 == 0 && m_traceInterval > 0){
+                time_t now = time(NULL);
+                int diff = int(now - m_lastTrace);
+                if (diff >= m_traceInterval){
+                    fprintf(stderr, "%s\n", current->m_path.str());
+                    m_lastTrace = now;
+                }
+            }
                }
        }
     // close all dirs with parents: